summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Sollich <hendrik@hoodie.de>2018-12-20 18:56:45 +0100
committerHendrik Sollich <hendrik@hoodie.de>2018-12-21 02:16:56 +0100
commit31c81d070a4f3a03fa95dc8eaeebc43d39f9d434 (patch)
tree13b473184e38c05db7a8f4bdc4f88e72cb2a8968
parentf44a168410a284a25c92a063576cf19a8f45c933 (diff)
simple clippy run
-rw-r--r--examples/tasks.rs6
-rw-r--r--src/calendar.rs2
-rw-r--r--src/components.rs6
-rw-r--r--src/properties.rs16
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<TZ:TimeZone>(&mut self, dt: DateTime<TZ>) -> &mut Self
+ pub fn due<TZ:TimeZone>(&mut self, dt: &DateTime<TZ>) -> &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<TZ:TimeZone>(&mut self, dt: DateTime<TZ>) -> &mut Self
+ pub fn completed<TZ:TimeZone>(&mut self, dt: &DateTime<TZ>) -> &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<Property> 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));
}
}