diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-04-19 06:03:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-19 06:03:12 +0200 |
| commit | 291e44b3815b95b02bba0bf873351a2b6dfd72b9 (patch) | |
| tree | e0e7a8c70f5cfdbf4e0861c44f5c91ad67cc9fd7 /src/libcore/tests | |
| parent | 7f450bd3ca9edd39b876293650d49dc17d200256 (diff) | |
| parent | 2605537012022980d5ec69ad11653794db935cf6 (diff) | |
| download | rust-291e44b3815b95b02bba0bf873351a2b6dfd72b9.tar.gz rust-291e44b3815b95b02bba0bf873351a2b6dfd72b9.zip | |
Rollup merge of #60023 - koalatux:nth-back, r=scottmcm
implement specialized nth_back() for Bytes, Fuse and Enumerate Hi, After my first PR has been successfully merged, here is my second pull request :-) Also this PR contains some specializations for the problem discussed in #54054.
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/iter.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index d5b581d336d..5247331fba2 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -390,6 +390,24 @@ fn test_iterator_enumerate_nth() { } #[test] +fn test_iterator_enumerate_nth_back() { + let xs = [0, 1, 2, 3, 4, 5]; + let mut it = xs.iter().enumerate(); + while let Some((i, &x)) = it.nth_back(0) { + assert_eq!(i, x); + } + + let mut it = xs.iter().enumerate(); + while let Some((i, &x)) = it.nth_back(1) { + assert_eq!(i, x); + } + + let (i, &x) = xs.iter().enumerate().nth_back(3).unwrap(); + assert_eq!(i, x); + assert_eq!(i, 2); +} + +#[test] fn test_iterator_enumerate_count() { let xs = [0, 1, 2, 3, 4, 5]; assert_eq!(xs.iter().enumerate().count(), 6); |
