easy-ext 0.1.0

An attribute macro for easily writing extension trait pattern.
Documentation

easy-ext

Build Status version documentation license Rustc Version

An attribute macro for easily writing extension trait pattern.

Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
easy-ext = "0.1"

The current version of easy-ext requires Rust 1.31 or later.

Examples

use easy_ext::ext;

#[ext(StrExt)]
impl str {
    fn foo(&self) -> String {
        /* */
    }
}

Code like this will be generated:

trait StrExt {
    fn foo(&self) -> String;
}

impl StrExt for str {
    fn foo(&self) -> String {
        /* */
    }
}

Supported items

Visibility

  • The generated extension trait inherits the visibility of the item in the original impl.

  • The visibility of all the items in the original impl must be identical.

See the test codes for more examples.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.