summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Sollich <hendrik@hoodie.de>2016-11-20 18:37:24 +0100
committerHendrik Sollich <hendrik@hoodie.de>2016-11-20 18:42:23 +0100
commit9a9671ec4cff2aa37e46356f1e0dd6382b928eba (patch)
tree901625684a49d2057ff79eb118856f5e6eb81bfe
parenta5ca909f3ef7779c99085701b95c589b1de9ed86 (diff)
satisfied clippy
-rw-r--r--src/calendar.rs8
-rw-r--r--src/components.rs14
-rw-r--r--src/lib.rs5
-rw-r--r--src/properties.rs6
4 files changed, 17 insertions, 16 deletions
diff --git a/src/calendar.rs b/src/calendar.rs
index d7cd121..52c087e 100644
--- a/src/calendar.rs
+++ b/src/calendar.rs
@@ -5,6 +5,7 @@ use std::ops::Deref;
use std::convert::Into;
+#[derive(Debug)]
pub enum CalendarElement{
Todo(Todo),
Event(Event)
@@ -34,6 +35,7 @@ impl CalendarElement {
/// Represents a calendar
///
/// You can `.add()` `Component`s to this.
+#[derive(Default,Debug)]
pub struct Calendar {
components: Vec<CalendarElement>
}
@@ -42,12 +44,10 @@ impl Calendar {
/// Creates a new Calendar.
pub fn new() -> Self {
- Calendar {
- components: Vec::new()
- }
+ Default::default()
}
- #[deprecated(note="Use .push instead")]
+ #[deprecated(note="Use .push() instead")]
#[doc(hidden)]
pub fn add<T:Into<CalendarElement>>(&mut self, component:T) -> &mut Self {
self.push(component)
diff --git a/src/components.rs b/src/components.rs
index 6cc48df..e574b8b 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -9,18 +9,18 @@ use std::collections::HashMap;
use properties::*;
/// VEVENT [(RFC 5545, Section 3.6.1 )](https://tools.ietf.org/html/rfc5545#section-3.6.1)
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct Event { properties: HashMap<String,Property> }
/// VTODO [(RFC 5545, Section 3.6.2 )](https://tools.ietf.org/html/rfc5545#section-3.6.2)
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct Todo { properties: HashMap<String,Property> }
impl Event {
/// Creates a new Event.
pub fn new() -> Self {
- Event { properties: HashMap::new() }
+ Default::default()
}
/// End of builder pattern.
@@ -40,7 +40,7 @@ impl Todo {
/// Creates a new Todo.
pub fn new() -> Self {
- Todo { properties: HashMap::new() }
+ Default::default()
}
/// End of builder pattern.
@@ -66,7 +66,7 @@ pub trait Component {
fn component_kind() -> &'static str;
/// Allows access to the inner properties HashMap.
- fn properties<'a>(&'a self) -> &'a HashMap<String,Property>;
+ fn properties(&self) -> &HashMap<String,Property>;
/// Writes `Component` into a `Writer` using `std::fmt`.
fn fmt_write<W: fmt::Write>(&self, out: &mut W) -> Result<(), fmt::Error> {
@@ -76,7 +76,7 @@ pub trait Component {
writeln!(out, "DTSTAMP:{}", now)?;
writeln!(out, "UID:{}", Uuid::new_v4())?;
- for (_, property) in self.properties() {
+ for property in self.properties().values() {
property.fmt_write(out)?;
}
writeln!(out, "END:{}", Self::component_kind())?;
@@ -187,7 +187,7 @@ macro_rules! component_impl {
fn component_kind() -> &'static str { $kind }
/// Read-only access to properties
- fn properties<'a>(&'a self) -> &'a HashMap<String, Property>{
+ fn properties(&self) -> &HashMap<String, Property> {
&self.properties
}
diff --git a/src/lib.rs b/src/lib.rs
index 1719604..aeda709 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -52,8 +52,9 @@
trivial_casts, trivial_numeric_casts,
unsafe_code,
unstable_features,
- unused_import_braces, unused_qualifications)]
-//#![warn(missing_debug_implementations)]
+ unused_import_braces, unused_qualifications,
+ missing_debug_implementations
+ )]
extern crate chrono;
extern crate uuid;
diff --git a/src/properties.rs b/src/properties.rs
index 216b026..5ae5332 100644
--- a/src/properties.rs
+++ b/src/properties.rs
@@ -73,7 +73,7 @@ impl Property {
/// Writes this Property to `out`
pub fn fmt_write<W: fmt::Write>(&self, out: &mut W) -> Result<(), fmt::Error> {
try!(write!(out, "{}", self.key));
- for (_key, &Parameter { ref key, ref value }) in &self.parameters {
+ for &Parameter { ref key, ref value } in self.parameters.values() {
try!(write!(out, ";{}={}", key, value));
}
try!(writeln!(out, ":{}", self.value));
@@ -82,7 +82,7 @@ impl Property {
}
/// Defines: `Public`, `Private`, `Confidential`
-#[derive(Copy,Clone)]
+#[derive(Copy,Clone,Debug)]
pub enum Class {
/// Public
Public,
@@ -107,7 +107,7 @@ impl Into<Property> for Class {
}
/// see 8.3.4. [Value Data Types Registry](https://tools.ietf.org/html/rfc5545#section-8.3.4)
-#[derive(Copy,Clone)]
+#[derive(Copy,Clone,Debug)]
pub enum ValueType{
/// Binary
Binary,