From 31c81d070a4f3a03fa95dc8eaeebc43d39f9d434 Mon Sep 17 00:00:00 2001 From: Hendrik Sollich Date: Thu, 20 Dec 2018 18:56:45 +0100 Subject: simple clippy run --- examples/tasks.rs | 6 +++--- src/calendar.rs | 2 +- src/components.rs | 6 +++--- src/properties.rs | 16 ++++++++-------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/tasks.rs b/examples/tasks.rs index da17db8..bdeea2d 100644 --- a/examples/tasks.rs +++ b/examples/tasks.rs @@ -12,9 +12,9 @@ fn main(){ .priority(12) .percent_complete(28) .status(TodoStatus::Completed) - .completed(Local::now()) - .due(Local::now()) - .due(Local::now()) + .completed(&Local::now()) + .due(&Local::now()) + .due(&Local::now()) .done(); println!("{}", todo.to_string()); diff --git a/src/calendar.rs b/src/calendar.rs index a6c3660..f0c817b 100644 --- a/src/calendar.rs +++ b/src/calendar.rs @@ -89,7 +89,7 @@ impl Calendar { /// FIXME code repetition pub fn print(&self) -> Result<(), fmt::Error> { let mut out = String::new(); - try!(self.fmt_write(&mut out)); + self.fmt_write(&mut out)?; print_crlf!("{}", out); Ok(()) } diff --git a/src/components.rs b/src/components.rs index 34e29d5..4cf50aa 100644 --- a/src/components.rs +++ b/src/components.rs @@ -79,7 +79,7 @@ impl Todo { /// Set the COMPLETED `Property`, date only - pub fn due(&mut self, dt: DateTime) -> &mut Self + pub fn due(&mut self, dt: &DateTime) -> &mut Self where TZ::Offset: fmt::Display { self.add_property("DUE", dt.format("%Y%m%dT%H%M%S").to_string().as_ref()); @@ -87,7 +87,7 @@ impl Todo { } /// Set the COMPLETED `Property`, date only - pub fn completed(&mut self, dt: DateTime) -> &mut Self + pub fn completed(&mut self, dt: &DateTime) -> &mut Self where TZ::Offset: fmt::Display { self.add_property("COMPLETED", dt.format("%Y%m%dT%H%M%S").to_string().as_ref()); @@ -237,7 +237,7 @@ pub trait Component { /// Prints to stdout fn print(&self) -> Result<(), fmt::Error> { let mut out = String::new(); - try!(self.fmt_write(&mut out)); + self.fmt_write(&mut out)?; print_crlf!("{}", out); Ok(()) } diff --git a/src/properties.rs b/src/properties.rs index 3ab8a6a..7e8c7f1 100644 --- a/src/properties.rs +++ b/src/properties.rs @@ -75,12 +75,12 @@ impl Property { // A nice starting capacity for the majority of content lines let mut line = String::with_capacity(150); - try!(write!(line, "{}", self.key)); + write!(line, "{}", self.key)?; for &Parameter { ref key, ref value } in self.parameters.values() { - try!(write!(line, ";{}={}", key, value)); + write!(line, ";{}={}", key, value)?; } - try!(write!(line, ":{}", self.value)); - try!(write_crlf!(out, "{}", fold_line(line))); + write!(line, ":{}", self.value)?; + write_crlf!(out, "{}", fold_line(&line))?; Ok(()) } } @@ -261,7 +261,7 @@ impl Into for TodoStatus { // Fold a content line as described in RFC 5545, Section 3.1 -fn fold_line(line: String) -> String { +fn fold_line(line: &str) -> String { let limit = 75; let len = line.len(); let mut ret = String::with_capacity(len + (len / limit * 3)); @@ -270,7 +270,7 @@ fn fold_line(line: String) -> String { let mut pos = 0; let mut next_pos = limit; while bytes_remaining > limit { - while line.is_char_boundary(next_pos) == false { + while !line.is_char_boundary(next_pos) { next_pos -= 1; } ret.push_str(&line[pos..next_pos]); @@ -293,7 +293,7 @@ mod tests { #[test] fn fold_line_short() { let line = String::from("This is a short line"); - assert_eq!(line.clone(), fold_line(line)); + assert_eq!(line.clone(), fold_line(&line)); } #[test] @@ -302,6 +302,6 @@ mod tests { of a UTF-8 character. 老虎."); let expected = String::from("Content lines shouldn't be folded in the middle \ of a UTF-8 character. 老\r\n 虎."); - assert_eq!(expected, fold_line(line)); + assert_eq!(expected, fold_line(&line)); } } -- cgit v1.2.3