-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Demoding in iter: any, all, map_to_vec, flat_map_to_vec, filter_to_vec
- Loading branch information
1 parent
f7e90fc
commit fec96b2
Showing
15 changed files
with
57 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
fn is_even(&&x: uint) -> bool { (x % 2u) == 0u } | ||
fn is_even(x: &uint) -> bool { (*x % 2) == 0 } | ||
|
||
fn main() { | ||
assert ![1u, 3u]/_.any(is_even); | ||
assert [1u, 2u]/_.any(is_even); | ||
assert ![]/_.any(is_even); | ||
|
||
assert !Some(1u).any(is_even); | ||
assert Some(2u).any(is_even); | ||
assert !Some(1).any(is_even); | ||
assert Some(2).any(is_even); | ||
assert !None.any(is_even); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
fn is_even(&&x: uint) -> bool { (x % 2u) == 0u } | ||
fn is_even(+x: uint) -> bool { (x % 2) == 0 } | ||
|
||
fn main() { | ||
assert [1u, 3u]/_.filter_to_vec(is_even) == ~[]; | ||
assert [1u, 2u, 3u]/_.filter_to_vec(is_even) == ~[2u]; | ||
assert [1, 3]/_.filter_to_vec(is_even) == ~[]; | ||
assert [1, 2, 3]/_.filter_to_vec(is_even) == ~[2]; | ||
assert None.filter_to_vec(is_even) == ~[]; | ||
assert Some(1u).filter_to_vec(is_even) == ~[]; | ||
assert Some(2u).filter_to_vec(is_even) == ~[2u]; | ||
assert Some(1).filter_to_vec(is_even) == ~[]; | ||
assert Some(2).filter_to_vec(is_even) == ~[2]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
fn inc(x: &uint) -> uint { *x + 1u } | ||
fn inc(+x: uint) -> uint { x + 1 } | ||
|
||
fn main() { | ||
assert [1u, 3u]/_.map_to_vec(inc) == ~[2u, 4u]; | ||
assert [1u, 2u, 3u]/_.map_to_vec(inc) == ~[2u, 3u, 4u]; | ||
assert [1, 3]/_.map_to_vec(inc) == ~[2, 4]; | ||
assert [1, 2, 3]/_.map_to_vec(inc) == ~[2, 3, 4]; | ||
assert None.map_to_vec(inc) == ~[]; | ||
assert Some(1u).map_to_vec(inc) == ~[2u]; | ||
assert Some(2u).map_to_vec(inc) == ~[3u]; | ||
assert Some(1).map_to_vec(inc) == ~[2]; | ||
assert Some(2).map_to_vec(inc) == ~[3]; | ||
} |