From 3cb9fa26ef9905c00a29ea577fb55a12a91c8e7b Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 20 Jan 2015 15:45:07 -0800 Subject: std: Rename Show/String to Debug/Display This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl FromError for Box` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436 --- src/libterm/terminfo/mod.rs | 2 +- src/libterm/terminfo/parm.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/libterm') diff --git a/src/libterm/terminfo/mod.rs b/src/libterm/terminfo/mod.rs index 4933938f338..2ef0bca3785 100644 --- a/src/libterm/terminfo/mod.rs +++ b/src/libterm/terminfo/mod.rs @@ -197,7 +197,7 @@ impl TerminfoTerminal { let mut file = entry.unwrap(); let ti = parse(&mut file, false); if ti.is_err() { - debug!("error parsing terminfo entry: {:?}", ti.unwrap_err()); + debug!("error parsing terminfo entry: {:?}", ti.err().unwrap()); return None; } diff --git a/src/libterm/terminfo/parm.rs b/src/libterm/terminfo/parm.rs index b0bce8f3112..0b51a976c0e 100644 --- a/src/libterm/terminfo/parm.rs +++ b/src/libterm/terminfo/parm.rs @@ -624,7 +624,7 @@ mod test { }; let res = get_res("%p1", cap, &[p], vars); assert!(res.is_ok(), - "Op {} failed with 1 stack entry: {}", cap, res.unwrap_err()); + "Op {} failed with 1 stack entry: {}", cap, res.err().unwrap()); } let caps = ["%+", "%-", "%*", "%/", "%m", "%&", "%|", "%A", "%O"]; for &cap in caps.iter() { @@ -636,7 +636,7 @@ mod test { "Binop {} succeeded incorrectly with 1 stack entry", cap); let res = get_res("%{1}%{2}", cap, &[], vars); assert!(res.is_ok(), - "Binop {} failed with 2 stack entries: {:?}", cap, res.unwrap_err()); + "Binop {} failed with 2 stack entries: {:?}", cap, res.err().unwrap()); } } @@ -651,15 +651,15 @@ mod test { for &(op, bs) in v.iter() { let s = format!("%{{1}}%{{2}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); - assert!(res.is_ok(), res.unwrap_err()); + assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), vec!(b'0' + bs[0])); let s = format!("%{{1}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); - assert!(res.is_ok(), res.unwrap_err()); + assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), vec!(b'0' + bs[1])); let s = format!("%{{2}}%{{1}}%{}%d", op); let res = expand(s.as_bytes(), &[], &mut Variables::new()); - assert!(res.is_ok(), res.unwrap_err()); + assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), vec!(b'0' + bs[2])); } } @@ -669,15 +669,15 @@ mod test { let mut vars = Variables::new(); let s = b"\\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m"; let res = expand(s, &[Number(1)], &mut vars); - assert!(res.is_ok(), res.unwrap_err()); + assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), "\\E[31m".bytes().collect::>()); let res = expand(s, &[Number(8)], &mut vars); - assert!(res.is_ok(), res.unwrap_err()); + assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), "\\E[90m".bytes().collect::>()); let res = expand(s, &[Number(42)], &mut vars); - assert!(res.is_ok(), res.unwrap_err()); + assert!(res.is_ok(), res.err().unwrap()); assert_eq!(res.unwrap(), "\\E[38;5;42m".bytes().collect::>()); } -- cgit 1.4.1-3-g733a5