aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Barnard2018-09-22 09:56:36 +0100
committerEdward Barnard2018-09-22 09:58:14 +0100
commitdf9e3a2c38775a0cefcc9793655de6d5c5ac2102 (patch)
tree86f55e9e23cc2d9b219067a49ca5e100e58169e8
parent5f941fdb51a7505b4ffdc4ef6948360264e9fff5 (diff)
downloadrust-plist-df9e3a2c38775a0cefcc9793655de6d5c5ac2102.tar.bz2
Make Date type implement Copy and Hash.
-rw-r--r--src/date.rs2
-rw-r--r--src/value.rs8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/date.rs b/src/date.rs
index f83b1af..ba7978f 100644
--- a/src/date.rs
+++ b/src/date.rs
@@ -6,7 +6,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
use Error;
/// A UTC timestamp. Used for serialization to and from the plist date type.
-#[derive(Clone, PartialEq)]
+#[derive(Clone, Copy, Hash, PartialEq)]
pub struct Date {
inner: SystemTime,
}
diff --git a/src/value.rs b/src/value.rs
index d27baba..237ecdf 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -141,9 +141,9 @@ impl Value {
/// If the `Value` is a Date, returns the associated `Date`.
///
/// Returns `None` otherwise.
- pub fn as_date(&self) -> Option<&Date> {
+ pub fn as_date(&self) -> Option<Date> {
match *self {
- Value::Date(ref date) => Some(date),
+ Value::Date(date) => Some(date),
_ => None,
}
}
@@ -224,7 +224,7 @@ impl From<Date> for Value {
impl<'a> From<&'a Date> for Value {
fn from(from: &'a Date) -> Value {
- Value::Date(from.clone())
+ Value::Date(*from)
}
}
@@ -471,7 +471,7 @@ mod tests {
);
let date: Date = SystemTime::now().into();
- assert_eq!(Value::Date(date.clone()).as_date(), Some(&date));
+ assert_eq!(Value::Date(date.clone()).as_date(), Some(date));
assert_eq!(Value::Real(0.0).as_real(), Some(0.0));
assert_eq!(Value::Integer(1).as_integer(), Some(1));