Skip to content

Commit 0c50312

Browse files
authored
Unrolled build for rust-lang#139149
Rollup merge of rust-lang#139149 - mejrs:itaf, r=ehuss unstable book: document import_trait_associated_functions Documents rust-lang#134691 which was implemented in rust-lang#134754
2 parents 946aea0 + 39a491a commit 0c50312

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# import_trait_associated_functions
2+
3+
The tracking issue for this feature is: [#134691]
4+
5+
[#134691]: https://github.com/rust-lang/rust/issues/134691
6+
7+
------------------------
8+
9+
This feature allows importing associated functions and constants from traits and then using them like regular items.
10+
11+
```rust
12+
#![feature(import_trait_associated_functions)]
13+
14+
use std::ops::Add::add;
15+
16+
fn main() {
17+
let numbers = vec![1, 2, 3, 4, 5, 6];
18+
let sum = numbers.into_iter().reduce(add); // instead of `.reduce(Add:add)`
19+
20+
assert_eq!(sum, Some(21));
21+
}
22+
```

0 commit comments

Comments
 (0)