Add a basic test to Option::replace
This commit is contained in:
parent
6035534586
commit
af87a3594a
2 changed files with 16 additions and 0 deletions
|
@ -44,6 +44,7 @@
|
|||
#![feature(reverse_bits)]
|
||||
#![feature(iterator_find_map)]
|
||||
#![feature(slice_internals)]
|
||||
#![feature(option_replace)]
|
||||
|
||||
extern crate core;
|
||||
extern crate test;
|
||||
|
|
|
@ -297,3 +297,18 @@ fn test_try() {
|
|||
}
|
||||
assert_eq!(try_option_err(), Err(NoneError));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_replace() {
|
||||
let mut x = Some(2);
|
||||
let old = x.replace(5);
|
||||
|
||||
assert_eq!(x, Some(5));
|
||||
assert_eq!(old, Some(2));
|
||||
|
||||
let mut x = None;
|
||||
let old = x.replace(3);
|
||||
|
||||
assert_eq!(x, Some(3));
|
||||
assert_eq!(old, None);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue