-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and tools
Description
https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.rposition
Description should provide a clear meaning for 'index' – index within the collection, or index as number of iteration?
Examples for rposition should demonstrate a clear difference from position.
Here's the example of rposition with an added comparison with the result of the situation with position.
let a = [1, 2, 3];
let mut iter_p = a.iter();
let mut iter_r = a.iter();
assert_eq!(iter_p.position(|&x| x == 2), iter_r.rposition(|&x| x == 2));
My proposition: use the same example as position(F)
let a = [1, 2, 3, 4];
let mut iter = a.iter();
assert_eq!(iter.rposition(|&x| x >= 2), Some(3));
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and tools