Skip to content

A macro to allow the use of "field_name: impl SomeTrait" in struct declarations.

License

Unknown and 3 other licenses found

Licenses found

Unknown
LICENSE
Apache-2.0
LICENSE-APACHE
ISC
LICENSE-ISC
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Kijewski/desugar-impl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

impl Trait not allowed outside of function and method return types

… but it is now!

This library gives you one macro, and one macro only: #[desugar_impl].

Annotate any struct, enum, or union with #[desugar_impl] to allow the use of field_name: impl SomeTrait in their declaration. E.g.

#[desugar_impl]
struct Test {
    a: impl Clone + PartialOrd,
    b: impl Clone + PartialOrd,
    c: impl Hash,
}

desugars to

struct Test<Ty1, Ty2, Ty3>
where
    Ty1: Clone + PartialOrd,
    Ty2: Clone + PartialOrd,
    Ty3: Hash,
{
    a: Ty1,
    b: Ty2,
    c: Ty3,
}

You can still place any #[derive(…)] macros just below #[desugar_impl], and they'll see the desugared code.

About

A macro to allow the use of "field_name: impl SomeTrait" in struct declarations.

Resources

License

Unknown and 3 other licenses found

Licenses found

Unknown
LICENSE
Apache-2.0
LICENSE-APACHE
ISC
LICENSE-ISC
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages