use zoet::zoet; // Check that #[cfg] is applied to the generated trait; if it's not, we will get a compile-time // failure complaining about conflicting (i.e. duplicate) implementations of Default. struct Foo(usize); #[zoet] impl Foo { #[cfg(unix)] #[zoet(Default)] fn unix_foo() -> Foo { Foo(0) } #[cfg(not(unix))] #[zoet(Default)] fn not_unix_foo() -> Foo { Foo(0) } } // Ditto but for free functions. #[cfg(unix)] #[zoet(AsRef)] fn unix_bar(foo: &Foo) -> &usize { &foo.0 } #[cfg(not(unix))] #[zoet(AsRef)] fn not_unix_bar(foo: &Foo) -> &usize { &foo.0 }