Debian Codegraph @

third_party/rust/extend/README.md

raw
1 # extend
2
3 [![Crates.io](https://img.shields.io/crates/v/extend.svg)](https://crates.io/crates/extend)
4 [![Docs](https://docs.rs/extend/badge.svg)](https://docs.rs/extend)
5 [![dependency status](https://deps.rs/repo/github/davidpdrsn/extend/status.svg)](https://deps.rs/repo/github/davidpdrsn/extend)
6 [![Build status](https://github.com/davidpdrsn/extend/workflows/CI/badge.svg)](https://github.com/davidpdrsn/extend/actions)
7 ![maintenance-status](https://img.shields.io/badge/maintenance-passively--maintained-yellowgreen.svg)
8
9 Create extensions for types you don't own with [extension traits] but without the boilerplate.
10
11 Example:
12
13 ```rust
14 use extend::ext;
15
16 #[ext]
17 impl<T: Ord> Vec<T> {
18 fn sorted(mut self) -> Self {
19 self.sort();
20 self
21 }
22 }
23
24 fn main() {
25 assert_eq!(
26 vec![1, 2, 3],
27 vec![2, 3, 1].sorted(),
28 );
29 }
30 ```
31
32 [extension traits]: https://dev.to/matsimitsu/extending-existing-functionality-in-rust-with-traits-in-rust-3622