diff options
| author | Lukas Lueg <lukas.lueg@gmail.com> | 2020-11-23 23:52:19 +0100 | 
|---|---|---|
| committer | Lukas Lueg <lukas.lueg@gmail.com> | 2020-11-23 23:52:19 +0100 | 
| commit | 3b015622be1245d00e2663ba3da38a00ceb583fb (patch) | |
| tree | 0e38546476318861fad413637de3bcf83ad24569 /library/core/tests | |
| parent | d9a105fdd46c926ae606777a46dd90e5b838f92f (diff) | |
| download | rust-3b015622be1245d00e2663ba3da38a00ceb583fb.tar.gz rust-3b015622be1245d00e2663ba3da38a00ceb583fb.zip | |
Add Peekable::peek_mut
Diffstat (limited to 'library/core/tests')
| -rw-r--r-- | library/core/tests/iter.rs | 11 | ||||
| -rw-r--r-- | library/core/tests/lib.rs | 1 | 
2 files changed, 12 insertions, 0 deletions
| diff --git a/library/core/tests/iter.rs b/library/core/tests/iter.rs index 75ca897cadc..6b8a989fa42 100644 --- a/library/core/tests/iter.rs +++ b/library/core/tests/iter.rs @@ -1134,6 +1134,17 @@ fn test_iterator_peekable_next_if_eq() { assert_eq!(it.next_if_eq(""), None); } +#[test] +fn test_iterator_peekable_mut() { + let mut it = vec![1, 2, 3].into_iter().peekable(); + if let Some(p) = it.peek_mut() { + if *p == 1 { + *p = 5; + } + } + assert_eq!(it.collect::<Vec<_>>(), vec![5, 2, 3]); +} + /// This is an iterator that follows the Iterator contract, /// but it is not fused. After having returned None once, it will start /// producing elements if .next() is called again. diff --git a/library/core/tests/lib.rs b/library/core/tests/lib.rs index 14ef03fd53e..1efb3b74118 100644 --- a/library/core/tests/lib.rs +++ b/library/core/tests/lib.rs @@ -56,6 +56,7 @@ #![feature(unwrap_infallible)] #![feature(option_unwrap_none)] #![feature(peekable_next_if)] +#![feature(peekable_peek_mut)] #![feature(partition_point)] #![feature(once_cell)] #![feature(unsafe_block_in_unsafe_fn)] | 
