aboutsummaryrefslogtreecommitdiff
path: root/tests/example.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/example.rs')
-rw-r--r--tests/example.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/example.rs b/tests/example.rs
new file mode 100644
index 0000000..bbe439b
--- /dev/null
+++ b/tests/example.rs
@@ -0,0 +1,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();
+}