diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-20 16:26:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-20 16:26:37 +0200 |
| commit | 60649e3a2efe34f8221e53e6cc0233d2dbd147ab (patch) | |
| tree | 8dd0e68c069706340383f3ed391fc0e0334d03ba /src/libcore/tests | |
| parent | a5299dd5d1c517b8a2da463ec463abec68b08b33 (diff) | |
| parent | d3019d16b992105d5948fae4a4fb17337ccac177 (diff) | |
| download | rust-60649e3a2efe34f8221e53e6cc0233d2dbd147ab.tar.gz rust-60649e3a2efe34f8221e53e6cc0233d2dbd147ab.zip | |
Rollup merge of #63265 - JohnTitor:implement-nth-back-for-chunksexactmut, r=scottmcm
Implement `nth_back` for ChunksExactMut This is a part of #54054. r? @scottmcm
Diffstat (limited to 'src/libcore/tests')
| -rw-r--r-- | src/libcore/tests/slice.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 4790152512a..6609bc3135a 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -375,6 +375,25 @@ fn test_chunks_exact_mut_nth() { } #[test] +fn test_chunks_exact_mut_nth_back() { + let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; + let mut c = v.chunks_exact_mut(2); + assert_eq!(c.nth_back(1).unwrap(), &[2, 3]); + assert_eq!(c.next().unwrap(), &[0, 1]); + assert_eq!(c.next(), None); + + let v2: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let mut c2 = v2.chunks_exact_mut(3); + assert_eq!(c2.nth_back(0).unwrap(), &[0, 1, 2]); + assert_eq!(c2.next(), None); + assert_eq!(c2.next_back(), None); + + let v3: &mut [i32] = &mut [0, 1, 2, 3, 4]; + let mut c3 = v3.chunks_exact_mut(10); + assert_eq!(c3.nth_back(0), None); +} + +#[test] fn test_chunks_exact_mut_last() { let v: &mut [i32] = &mut [0, 1, 2, 3, 4, 5]; let c = v.chunks_exact_mut(2); |
