diff --git a/src/lib.rs b/src/lib.rs index b967715..e6fe893 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) } } @@ -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()); }