Update Examples
parent
dec41efd58
commit
8e5ef3d743
19
Examples.md
19
Examples.md
@ -1189,19 +1189,20 @@ fn main
|
||||
let vec1 = vec![1, 2, 3]
|
||||
vec2 = vec![4, 5, 6]
|
||||
|
||||
println! "2 in vec1: {}", vec1.iter() .any(|&x| x == 2));
|
||||
println!("2 in vec2: {}", vec2.into_iter().any(|x| x == 2));
|
||||
//! Note use of fragment of loop construct to just get the corresponding iterator
|
||||
println! "2 in vec1: {}", &in vec1.any &x => x == 2
|
||||
println! "2 in vec2: {}", in vec2.any x => x == 2
|
||||
|
||||
println!("vec1 len: {}", vec1.len());
|
||||
println!("First element of vec1 is: {}", vec1[0]);
|
||||
println! "vec1 len: {}", vec1.len()
|
||||
println! "First element of vec1 is: {}", vec1[0]
|
||||
// `into_iter()` does move `vec2` and its elements, so they cannot be used again
|
||||
|
||||
let array1 = [1, 2, 3];
|
||||
let array2 = [4, 5, 6];
|
||||
let array1 = [1, 2, 3]
|
||||
array2 = [4, 5, 6]
|
||||
|
||||
println! "2 in array1: {}", &in array1.any &x => x == 2
|
||||
println!("2 in array2: {}", in array2.any x => x == 2
|
||||
|
||||
println!("2 in array1: {}", array1.iter() .any(|&x| x == 2));
|
||||
println!("2 in array2: {}", array2.into_iter().any(|x| x == 2));
|
||||
}
|
||||
```
|
||||
</td></tr></table>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user