From 97087a8b481ee90314e1dd6011a90768a822457e Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Thu, 22 Jan 2015 20:49:54 -0200 Subject: [PATCH 1/2] Show and String have become Debug and Display --- src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b967715..3166018 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,27 +135,27 @@ impl Ascii { } } -impl fmt::String for Ascii { +impl fmt::Display for Ascii { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::String::fmt(&(self.chr as char), f) + fmt::Display::fmt(&(self.chr as char), f) } } -impl fmt::String for Vec { +impl fmt::Display for Vec { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::String::fmt(&self[], f) + fmt::Display::fmt(&self[], f) } } -impl fmt::String for [Ascii] { +impl fmt::Display for [Ascii] { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::String::fmt(self.as_str(), f) + fmt::Display::fmt(self.as_str(), f) } } -impl fmt::Show for Ascii { +impl fmt::Debug for Ascii { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Show::fmt(&(self.chr as char), f) + fmt::Debug::fmt(&(self.chr as char), f) } } From f52a8ddbadf480857886fe13aaaed96af237bda4 Mon Sep 17 00:00:00 2001 From: Renato Zannon Date: Thu, 22 Jan 2015 20:50:33 -0200 Subject: [PATCH 2/2] Result<_, ()> doesn't implement unwrap anymore --- src/lib.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 3166018..e6fe893 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -344,30 +344,30 @@ mod tests { #[test] fn test_ascii() { - assert_eq!(65u8.to_ascii().unwrap().as_byte(), 65u8); - assert_eq!(65u8.to_ascii().unwrap().as_char(), 'A'); - assert_eq!('A'.to_ascii().unwrap().as_char(), 'A'); - assert_eq!('A'.to_ascii().unwrap().as_byte(), 65u8); + assert_eq!(65u8.to_ascii().ok().unwrap().as_byte(), 65u8); + assert_eq!(65u8.to_ascii().ok().unwrap().as_char(), 'A'); + assert_eq!('A'.to_ascii().ok().unwrap().as_char(), 'A'); + assert_eq!('A'.to_ascii().ok().unwrap().as_byte(), 65u8); - assert!('0'.to_ascii().unwrap().is_digit()); - assert!('9'.to_ascii().unwrap().is_digit()); - assert!(!'/'.to_ascii().unwrap().is_digit()); - assert!(!':'.to_ascii().unwrap().is_digit()); + assert!('0'.to_ascii().ok().unwrap().is_digit()); + assert!('9'.to_ascii().ok().unwrap().is_digit()); + assert!(!'/'.to_ascii().ok().unwrap().is_digit()); + assert!(!':'.to_ascii().ok().unwrap().is_digit()); - assert!(0x1f_u8.to_ascii().unwrap().is_control()); - assert!(!' '.to_ascii().unwrap().is_control()); - assert!(0x7f_u8.to_ascii().unwrap().is_control()); + assert!(0x1f_u8.to_ascii().ok().unwrap().is_control()); + assert!(!' '.to_ascii().ok().unwrap().is_control()); + assert!(0x7f_u8.to_ascii().ok().unwrap().is_control()); } #[test] fn test_ascii_vec() { let test = &[40u8, 32u8, 59u8]; let b: &[_] = v2ascii!([40, 32, 59]); - assert_eq!(test.to_ascii().unwrap(), b); - assert_eq!("( ;".to_ascii().unwrap(), b); + assert_eq!(test.to_ascii().ok().unwrap(), b); + assert_eq!("( ;".to_ascii().ok().unwrap(), b); let v = vec![40u8, 32u8, 59u8]; - assert_eq!(v.as_slice().to_ascii().unwrap(), b); - assert_eq!("( ;".to_string().as_slice().to_ascii().unwrap(), b); + assert_eq!(v.as_slice().to_ascii().ok().unwrap(), b); + assert_eq!("( ;".to_string().as_slice().to_ascii().ok().unwrap(), b); } #[test] @@ -431,7 +431,7 @@ mod tests { #[test] fn fmt_string_ascii_slice() { - let s = "abc".to_ascii().unwrap(); + let s = "abc".to_ascii().ok().unwrap(); assert_eq!(format!("{}", s), "abc".to_string()); }