extend

Create extensions for types you don't own with [extension traits] but without the boilerplate.

Example:

```rust use extend::ext;

[ext]

impl Vec { fn sorted(mut self) -> Self { self.sort(); self } }

fn main() { assert_eq!( vec![1, 2, 3], vec![2, 3, 1].sorted(), ); } ```

How does it work?

Under the hood it generates a trait with methods in your impl and implements those for the type you specify. The code shown above expands roughly to:

```rust trait VecExt { fn sorted(mut self) -> Self; }

impl VecExt for Vec { fn sorted(mut self) -> Self { self.sort(); self } } ```

Configuration

You can configure:

More examples:

```rust use extend::ext;

[ext(name = SortedVecExt)]

impl Vec { fn sorted(mut self) -> Self { self.sort(); self } }

[ext(pub(crate))]

impl i32 { fn double(self) -> i32 { self * 2 } }

[ext(pub, name = ResultSafeUnwrapExt)]

impl Result { fn safeunwrap(self) -> T { match self { Ok(t) => t, Err() => unreachable!(), } } } ```

License: MIT