Skip to content

Releases: ObsidianMinor/trapper

trapper: proc macro edition

01 Aug 00:37
Compare
Choose a tag to compare

This new version implements newtype via a procedural macro. This makes it incredibly flexible, allowing for all sorts of generics, lifetimes, constraints, attributes, and an optional semicolon. However, because it's a proc macro, it's unhygenic, which means you can't use it in statement contexts (like in functions) on stable. So, the lib is now 2.0.0. You shouldn't have to change anything as trapper re-exports newtype from trapper_macro except if you use it in statements.

newtype!(pub type X<'a, T>(&'a T)); // allowed
newtype!(pub type Y<'a, 'b: 'a, T = std::io::StderrLock<'a>>(&'b T) where T: Read); // now allowed
newtype! {
    pub type Z(i32); // optional semi now allowed
}

fn main() {
    newtype!(pub type A(i64)); // not allowed anymore except with proc_macro_hygiene feature
}