diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2018-03-01 01:57:25 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2018-03-01 01:57:25 -0800 |
| commit | 70d5a4600b21451aa98b447cd59384d86e2eadce (patch) | |
| tree | 5d1a396c78855cb8a510c3e69282f129c19cb4bf /src/libcore/tests | |
| parent | a85417f5938023d1491b44d94da705f539bb8b17 (diff) | |
Specialize Zip::nth for TrustedRandomAccess
Makes the bench asked about on URLO 58x faster :)
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/iter.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index edd75f7795e..5e2fef95d26 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -145,6 +145,23 @@ fn test_iterator_chain_find() { } #[test] +fn test_zip_nth() { + let xs = [0, 1, 2, 4, 5]; + let ys = [10, 11, 12]; + + let mut it = xs.iter().zip(&ys); + assert_eq!(it.nth(0), Some((&0, &10))); + assert_eq!(it.nth(1), Some((&2, &12))); + assert_eq!(it.nth(0), None); + + let mut it = xs.iter().zip(&ys); + assert_eq!(it.nth(3), None); + + let mut it = ys.iter().zip(&xs); + assert_eq!(it.nth(3), None); +} + +#[test] fn test_iterator_step_by() { // Identity let mut it = (0..).step_by(1).take(3); |
