aboutsummaryrefslogtreecommitdiff
path: root/tests/example.rs
blob: bbe439bbfa58b1a4878bdfaf3d3111478c5a92bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#![cfg_attr(feature = "used_linker", feature(used_with_arg))]
#![deny(warnings)]
#![allow(clippy::no_effect_underscore_binding)]

use linkme::distributed_slice;

pub struct Bencher;

#[distributed_slice]
pub static BENCHMARKS: [fn(&mut Bencher)] = [..];

#[distributed_slice(BENCHMARKS)]
static BENCH_DESERIALIZE: fn(&mut Bencher) = bench_deserialize;

fn bench_deserialize(_b: &mut Bencher) {
    /* ... */
}

#[test]
fn readme() {
    // Iterate the elements.
    for _bench in BENCHMARKS { /* ... */ }

    // Index into the elements.
    let _first = BENCHMARKS[0];

    // Slice the elements.
    let _except_first = &BENCHMARKS[1..];

    // Invoke methods on the underlying slice.
    let _len = BENCHMARKS.len();
}