diff options
author | Pierre-Henri Symoneaux <phsym@users.noreply.github.com> | 2019-08-26 22:00:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-26 22:00:25 +0200 |
commit | 6bb234c979f8153f8ee8eede5cbb9a1ae2658f23 (patch) | |
tree | 3240b3ffdd53f569627d63484030bba6f15b3dd2 /src/utils.rs | |
parent | bdfb15081cf5e44934a08941f18a6eaba8275e1e (diff) | |
parent | 2040ec8190518db84d1651c596950488750ab567 (diff) |
Merge pull request #114 from phsym/printstd-nopanic
Remove panic in print_tty and return a Result
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/utils.rs b/src/utils.rs index dbd8db1..a3ce2ef 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -8,9 +8,9 @@ use unicode_width::UnicodeWidthStr; use super::format::Alignment; #[cfg(any(not(windows), not(feature="win_crlf")))] -pub static NEWLINE: &'static [u8] = b"\n"; +pub static NEWLINE: &[u8] = b"\n"; #[cfg(all(windows, feature="win_crlf"))] -pub static NEWLINE: &'static [u8] = b"\r\n"; +pub static NEWLINE: &[u8] = b"\r\n"; /// Internal utility for writing data into a string pub struct StringWriter { @@ -152,10 +152,10 @@ mod tests { #[test] fn string_writer() { let mut out = StringWriter::new(); - out.write("foo".as_bytes()).unwrap(); - out.write(" ".as_bytes()).unwrap(); - out.write("".as_bytes()).unwrap(); - out.write("bar".as_bytes()).unwrap(); + out.write_all(b"foo").unwrap(); + out.write_all(b" ").unwrap(); + out.write_all(b"").unwrap(); + out.write_all(b"bar").unwrap(); assert_eq!(out.as_string(), "foo bar"); } @@ -200,7 +200,7 @@ mod tests { #[test] fn utf8_error() { let mut out = StringWriter::new(); - let res = out.write_all(&vec![0, 255]); + let res = out.write_all(&[0, 255]); assert!(res.is_err()); } } |