An attribute macro for easily writing extension trait pattern.
Add this to your Cargo.toml
:
toml
[dependencies]
easy-ext = "0.1"
The current version of easy-ext requires Rust 1.31 or later.
```rust use easy_ext::ext;
impl str { fn foo(&self) -> String { /* */ } } ```
Code like this will be generated:
```rust trait StrExt { fn foo(&self) -> String; }
impl StrExt for str { fn foo(&self) -> String { /* */ } } ```
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.
Licensed under either of
at your option.
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.