diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-09-27 17:02:31 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-09-30 23:21:18 -0700 |
| commit | a8ba31dbf3e7d80a069bc486a35eff8357282b68 (patch) | |
| tree | 8a00829d527c443d16988b98cd7c97f1d3d4dac6 /src/libstd/option.rs | |
| parent | aaf6cc3a841095a95a9c74a6a2a3709dffd7a4e9 (diff) | |
| download | rust-a8ba31dbf3e7d80a069bc486a35eff8357282b68.tar.gz rust-a8ba31dbf3e7d80a069bc486a35eff8357282b68.zip | |
std: Remove usage of fmt!
Diffstat (limited to 'src/libstd/option.rs')
| -rw-r--r-- | src/libstd/option.rs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/libstd/option.rs b/src/libstd/option.rs index a8d4cf541ce..033515875dd 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -278,7 +278,7 @@ impl<T> Option<T> { pub fn get_ref<'a>(&'a self) -> &'a T { match *self { Some(ref x) => x, - None => fail!("called `Option::get_ref()` on a `None` value"), + None => fail2!("called `Option::get_ref()` on a `None` value"), } } @@ -298,7 +298,7 @@ impl<T> Option<T> { pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { match *self { Some(ref mut x) => x, - None => fail!("called `Option::get_mut_ref()` on a `None` value"), + None => fail2!("called `Option::get_mut_ref()` on a `None` value"), } } @@ -320,7 +320,7 @@ impl<T> Option<T> { pub fn unwrap(self) -> T { match self { Some(x) => x, - None => fail!("called `Option::unwrap()` on a `None` value"), + None => fail2!("called `Option::unwrap()` on a `None` value"), } } @@ -333,7 +333,7 @@ impl<T> Option<T> { #[inline] pub fn take_unwrap(&mut self) -> T { if self.is_none() { - fail!("called `Option::take_unwrap()` on a `None` value") + fail2!("called `Option::take_unwrap()` on a `None` value") } self.take().unwrap() } @@ -348,7 +348,7 @@ impl<T> Option<T> { pub fn expect(self, reason: &str) -> T { match self { Some(val) => val, - None => fail!(reason.to_owned()), + None => fail2!("{}", reason.to_owned()), } } @@ -722,21 +722,23 @@ mod tests { let new_val = 11; let mut x = Some(val); - let mut it = x.mut_iter(); + { + let mut it = x.mut_iter(); - assert_eq!(it.size_hint(), (1, Some(1))); + assert_eq!(it.size_hint(), (1, Some(1))); - match it.next() { - Some(interior) => { - assert_eq!(*interior, val); - *interior = new_val; - assert_eq!(x, Some(new_val)); + match it.next() { + Some(interior) => { + assert_eq!(*interior, val); + *interior = new_val; + } + None => assert!(false), } - None => assert!(false), - } - assert_eq!(it.size_hint(), (0, Some(0))); - assert!(it.next().is_none()); + assert_eq!(it.size_hint(), (0, Some(0))); + assert!(it.next().is_none()); + } + assert_eq!(x, Some(new_val)); } #[test] |
