diff options
author | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-06-05 15:34:54 +0200 |
---|---|---|
committer | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-06-05 16:31:04 +0200 |
commit | 4e36ac179fc5341b35221018573e265a1f1a0a53 (patch) | |
tree | 629b1332d2600cafd9292c4426c85de04624108d /src/utils.rs | |
parent | 14dcf5f9615eeafb8eb7c20732f55d41d1045884 (diff) |
Fixed lint (+clippy) warnings and line endings
Added some lint rustc checks and fixed warnings.
Fixed some clippy warnings & errors
Converted remaining CRLF line endings to LF
Diffstat (limited to 'src/utils.rs')
-rw-r--r-- | src/utils.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/utils.rs b/src/utils.rs index 8f4bbf3..c00b2d7 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -30,12 +30,12 @@ impl StringWriter { impl Write for StringWriter { fn write(&mut self, data: &[u8]) -> Result<usize, Error> { - let string = match str::from_utf8(data) {
- Ok(s) => s,
+ let string = match str::from_utf8(data) { + Ok(s) => s, Err(e) => { return Err(Error::new(ErrorKind::Other, format!("Cannot decode utf8 string : {}", e))) - }
+ } }; self.string.push_str(string); Ok(data.len()) @@ -59,18 +59,18 @@ pub fn print_align<T: Write + ?Sized>(out: &mut T, -> Result<(), Error> { let text_len = UnicodeWidthStr::width(text); let mut nfill = if text_len < size { size - text_len } else { 0 }; - let n = match align {
- Alignment::LEFT => 0,
- Alignment::RIGHT => nfill,
- Alignment::CENTER => nfill / 2,
+ let n = match align { + Alignment::LEFT => 0, + Alignment::RIGHT => nfill, + Alignment::CENTER => nfill / 2, }; if n > 0 { - try!(out.write(&vec![fill as u8; n])); + try!(out.write_all(&vec![fill as u8; n])); nfill -= n; } - try!(out.write(text.as_bytes())); + try!(out.write_all(text.as_bytes())); if nfill > 0 && !skip_right_fill { - try!(out.write(&vec![fill as u8; nfill])); + try!(out.write_all(&vec![fill as u8; nfill])); } Ok(()) } |