Skip to main content

double_trait/
lib.rs

1// Reexport the double macro from our derive crate
2pub use double_derive::dummies;
3
4/// A general purpose test Dummy. Implements any interface annotadet with the [`dummies`] macro as
5/// well as a number of traits from the `std` namespace.
6///
7/// [`Dummy`] will implement any annotated trait trivially. For a trait `MyTrait` annotated with
8/// [`dummies`] the implementation is:
9///
10/// ```no_run
11/// # use double_trait::Dummy;
12/// # trait MyTrait {}
13/// impl MyTrait for Dummy {}
14/// ```
15///
16/// This works, because after being annotated with [`dummies`] every trait method has a default
17/// implementation. Even if it is just panicing.
18///
19/// ```no_run
20/// use double_trait::{dummies, Dummy};
21///
22/// #[dummies]
23/// trait OrgTrait {
24///     fn answer(&self) -> i32;
25/// }
26///
27/// OrgTrait::answer(&Dummy); // Compiles, but raises panic with `unimplemented!()`
28/// ```
29#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
30pub struct Dummy;