diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2017-01-13 10:42:32 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-13 10:42:32 +0100 |
| commit | 7c9ac4f5a6827bf0ee8458a9d08642a8c62d55e8 (patch) | |
| tree | 13f2eedaaa0af267580c41540d8ab94a8193e400 /src/test/incremental/thinlto | |
| parent | 6d2fb1225217a387f25e671210648231ddffcf45 (diff) | |
| parent | bf0253475026bed9cedc849f709045e65ec2b821 (diff) | |
| download | rust-7c9ac4f5a6827bf0ee8458a9d08642a8c62d55e8.tar.gz rust-7c9ac4f5a6827bf0ee8458a9d08642a8c62d55e8.zip | |
Rollup merge of #38995 - petrochenkov:minmax, r=GuillaumeGomez
Fix docs for min/max algorithms
I thought at first "what did they think about when stabilizing this!?", but it turned out it's just wrong docs. Phew.
r? @steveklabnik
Test:
```
use std::cmp::Ordering;
struct S(u8, u8);
impl PartialEq for S {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl PartialOrd for S {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.0.cmp(&other.0))
}
}
impl Ord for S {
fn cmp(&self, other: &Self) -> Ordering {
self.0.cmp(&other.0)
}
}
fn main() {
let arr = [S(0, 1), S(0, 2)];
println!("min {:?}", arr.iter().min());
println!("min_by {:?}", arr.iter().min_by(|x, y| x.0.cmp(&y.0)));
println!("min_by_key {:?}", arr.iter().min_by_key(|x| x.0));
println!("max {:?}", arr.iter().max());
println!("max_by {:?}", arr.iter().max_by(|x, y| x.0.cmp(&y.0)));
println!("max_by_key {:?}", arr.iter().max_by_key(|x| x.0));
}
```
Output:
```
rustc 1.15.0-beta.3 (a035041ba 2017-01-07)
min Some(S(0, 1))
min_by Some(S(0, 1))
min_by_key Some(S(0, 1))
max Some(S(0, 2))
max_by Some(S(0, 2))
max_by_key Some(S(0, 2))
```
Diffstat (limited to 'src/test/incremental/thinlto')
0 files changed, 0 insertions, 0 deletions
