Skip to content

v0.3.0 -- Generics now supported

Pre-release
Pre-release
Compare
Choose a tag to compare
@ErichDonGubler ErichDonGubler released this 15 Aug 22:15
· 25 commits to master since this release

This just in: generics are now supported in Adhesion! With the help of macros drawn from the parse-generics-shim crate, you can now write functions kind of like the ones you can find in the new tests associated with this release:

contract! {
    fn add_together1<T: ::std::ops::Add>(left: T, right: T) -> <T as std::ops::Add>::Output {
        // ...
    }
}

contract! {
    fn add_together2<T>(left: T, right: T) -> T::Output where T: ::std::ops::Add {
        // ...
    }
}

There are some limitations associated with the current handling of generics in macros, but they should accommodate a majority of use cases until a better solution is provided by Rust itself for generics parsing in macros.

Acknowledgements

@DanielKeep and his parse-generics-shim crate has been essential in making this release possible. Thank you so much!