From c11b6deb5a5bfeda16c4d40cf31501fbd28d759f Mon Sep 17 00:00:00 2001 From: Kang Seonghoon Date: Sat, 21 Feb 2015 18:14:09 +0900 Subject: [PATCH] 0.2.1: language changes. - `std::hash` has been renewed. - `DelayedFormat` no longer has a redundant lifetime. --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- README.md | 2 +- src/date.rs | 8 ++++---- src/datetime.rs | 8 ++++---- src/format/mod.rs | 10 +++++----- src/lib.rs | 4 ++-- src/naive/date.rs | 12 ++++++------ src/naive/datetime.rs | 11 +++++++---- src/naive/time.rs | 11 +++++++---- 10 files changed, 43 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a134ce7..68c1b62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ Chrono obeys the principle of [Semantic Versioning](http://semver.org/). There were/are numerous minor versions before 1.0 due to the language changes. Versions with only mechnical changes will be omitted from the following list. +## 0.2.1 (2015-02-21) + +### Changed + +- `DelayedFormat` no longer conveys a redundant lifetime. + ## 0.2.0 (2015-02-19) ### Added diff --git a/Cargo.toml b/Cargo.toml index 36466f8..2a11f61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chrono" -version = "0.2.0" +version = "0.2.1" authors = ["Kang Seonghoon "] description = "Date and time library for Rust" diff --git a/README.md b/README.md index eb6328a..661cadf 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[Chrono][doc] 0.2.0 +[Chrono][doc] 0.2.1 =================== [![Chrono on Travis CI][travis-image]][travis] diff --git a/src/date.rs b/src/date.rs index 90f761c..a726ead 100644 --- a/src/date.rs +++ b/src/date.rs @@ -224,7 +224,7 @@ fn map_local(d: &Date, mut f: F) -> Option> impl Date where Tz::Offset: fmt::Display { /// Formats the date with the specified formatting items. #[inline] - pub fn format_with_items<'a, I>(&'a self, items: I) -> DelayedFormat<'a, I> + pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { DelayedFormat::new_with_offset(Some(self.naive_local()), None, &self.offset, items) } @@ -232,7 +232,7 @@ impl Date where Tz::Offset: fmt::Display { /// Formats the date with the specified format string. /// See the `format::strftime` module on the supported escape sequences. #[inline] - pub fn format<'a>(&'a self, fmt: &'a str) -> DelayedFormat<'a, StrftimeItems<'a>> { + pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat> { self.format_with_items(StrftimeItems::new(fmt)) } } @@ -301,8 +301,8 @@ impl Ord for Date { fn cmp(&self, other: &Date) -> Ordering { self.date.cmp(&other.date) } } -impl hash::Hash for Date { - fn hash(&self, state: &mut H) { self.date.hash(state) } +impl hash::Hash for Date { + fn hash(&self, state: &mut H) { self.date.hash(state) } } impl Add for Date { diff --git a/src/datetime.rs b/src/datetime.rs index bace9d6..de6d4bb 100644 --- a/src/datetime.rs +++ b/src/datetime.rs @@ -171,7 +171,7 @@ impl DateTime where Tz::Offset: fmt::Display { /// Formats the combined date and time with the specified formatting items. #[inline] - pub fn format_with_items<'a, I>(&'a self, items: I) -> DelayedFormat<'a, I> + pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { let local = self.naive_local(); DelayedFormat::new_with_offset(Some(local.date()), Some(local.time()), &self.offset, items) @@ -180,7 +180,7 @@ impl DateTime where Tz::Offset: fmt::Display { /// Formats the combined date and time with the specified format string. /// See the `format::strftime` module on the supported escape sequences. #[inline] - pub fn format<'a>(&'a self, fmt: &'a str) -> DelayedFormat<'a, StrftimeItems<'a>> { + pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat> { self.format_with_items(StrftimeItems::new(fmt)) } } @@ -276,8 +276,8 @@ impl Ord for DateTime { fn cmp(&self, other: &DateTime) -> Ordering { self.datetime.cmp(&other.datetime) } } -impl hash::Hash for DateTime { - fn hash(&self, state: &mut H) { self.datetime.hash(state) } +impl hash::Hash for DateTime { + fn hash(&self, state: &mut H) { self.datetime.hash(state) } } impl Add for DateTime { diff --git a/src/format/mod.rs b/src/format/mod.rs index 9391b89..9209866 100644 --- a/src/format/mod.rs +++ b/src/format/mod.rs @@ -410,7 +410,7 @@ pub mod strftime; /// A *temporary* object which can be used as an argument to `format!` or others. /// This is normally constructed via `format` methods of each date and time type. #[derive(Debug)] -pub struct DelayedFormat<'a, I: Iterator> + Clone> { +pub struct DelayedFormat { /// The date view, if any. date: Option, /// The time view, if any. @@ -421,22 +421,22 @@ pub struct DelayedFormat<'a, I: Iterator> + Clone> { items: I, } -impl<'a, I: Iterator> + Clone> DelayedFormat<'a, I> { +impl<'a, I: Iterator> + Clone> DelayedFormat { /// Makes a new `DelayedFormat` value out of local date and time. - pub fn new(date: Option, time: Option, items: I) -> DelayedFormat<'a, I> { + pub fn new(date: Option, time: Option, items: I) -> DelayedFormat { DelayedFormat { date: date, time: time, off: None, items: items } } /// Makes a new `DelayedFormat` value out of local date and time and UTC offset. pub fn new_with_offset(date: Option, time: Option, - offset: &Off, items: I) -> DelayedFormat<'a, I> + offset: &Off, items: I) -> DelayedFormat where Off: Offset + fmt::Display { let name_and_diff = (offset.to_string(), offset.local_minus_utc()); DelayedFormat { date: date, time: time, off: Some(name_and_diff), items: items } } } -impl<'a, I: Iterator> + Clone> fmt::Display for DelayedFormat<'a, I> { +impl<'a, I: Iterator> + Clone> fmt::Display for DelayedFormat { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { format(f, self.date.as_ref(), self.time.as_ref(), self.off.as_ref(), self.items.clone()) } diff --git a/src/lib.rs b/src/lib.rs index 9637f39..a0f1838 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ /*! -# Chrono 0.2.0 +# Chrono 0.2.1 Date and time handling for Rust. (also known as `rust-chrono`) It aims to be a feature-complete superset of the [time](https://github.com/rust-lang/time) library. @@ -266,7 +266,7 @@ Advanced time zone handling is not yet supported (but is planned in 0.3). #![doc(html_root_url = "https://lifthrasiir.github.io/rust-chrono/")] -#![feature(core, collections, hash, std_misc)] // lib stability features as per RFC #507 +#![feature(core, collections, std_misc)] // lib stability features as per RFC #507 #![cfg_attr(test, feature(test))] // ditto #![deny(missing_docs)] diff --git a/src/naive/date.rs b/src/naive/date.rs index 2d62220..3c3c5d1 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -369,7 +369,7 @@ impl NaiveDate { /// Formats the date with the specified formatting items. #[inline] - pub fn format_with_items<'a, I>(&'a self, items: I) -> DelayedFormat<'a, I> + pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { DelayedFormat::new(Some(self.clone()), None, items) } @@ -377,7 +377,7 @@ impl NaiveDate { /// Formats the date with the specified format string. /// See the `format::strftime` module on the supported escape sequences. #[inline] - pub fn format<'a>(&'a self, fmt: &'a str) -> DelayedFormat<'a, StrftimeItems<'a>> { + pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat> { self.format_with_items(StrftimeItems::new(fmt)) } } @@ -452,8 +452,8 @@ impl Datelike for NaiveDate { } } -impl hash::Hash for NaiveDate { - fn hash(&self, state: &mut H) { self.ymdf.hash(state) } +impl hash::Hash for NaiveDate { + fn hash(&self, state: &mut H) { self.ymdf.hash(state) } } impl Add for NaiveDate { @@ -1112,7 +1112,7 @@ mod internals { pub const MAX_MDL: u32 = (12 << 6) | (31 << 1) | 1; const XX: i8 = -128; - static MDL_TO_OL: [i8; (MAX_MDL as usize + 1us)] = [ + static MDL_TO_OL: [i8; (MAX_MDL as usize + 1)] = [ XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, XX, @@ -1167,7 +1167,7 @@ mod internals { 98,100, 98,100, 98,100, 98,100, 98,100, 98,100, 98,100, 98,100, // 12 ]; - static OL_TO_MDL: [u8; (MAX_OL as usize + 1us)] = [ + static OL_TO_MDL: [u8; (MAX_OL as usize + 1)] = [ 0, 0, // 0 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, diff --git a/src/naive/datetime.rs b/src/naive/datetime.rs index 6b372c9..9838200 100644 --- a/src/naive/datetime.rs +++ b/src/naive/datetime.rs @@ -158,7 +158,7 @@ impl NaiveDateTime { /// Formats the combined date and time with the specified formatting items. #[inline] - pub fn format_with_items<'a, I>(&'a self, items: I) -> DelayedFormat<'a, I> + pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { DelayedFormat::new(Some(self.date.clone()), Some(self.time.clone()), items) } @@ -166,7 +166,7 @@ impl NaiveDateTime { /// Formats the combined date and time with the specified format string. /// See the `format::strftime` module on the supported escape sequences. #[inline] - pub fn format<'a>(&'a self, fmt: &'a str) -> DelayedFormat<'a, StrftimeItems<'a>> { + pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat> { self.format_with_items(StrftimeItems::new(fmt)) } } @@ -245,8 +245,11 @@ impl Timelike for NaiveDateTime { } } -impl hash::Hash for NaiveDateTime { - fn hash(&self, state: &mut H) { self.date.hash(state); self.time.hash(state) } +impl hash::Hash for NaiveDateTime { + fn hash(&self, state: &mut H) { + self.date.hash(state); + self.time.hash(state); + } } impl Add for NaiveDateTime { diff --git a/src/naive/time.rs b/src/naive/time.rs index f0abb8e..ea51318 100644 --- a/src/naive/time.rs +++ b/src/naive/time.rs @@ -128,7 +128,7 @@ impl NaiveTime { /// Formats the time with the specified formatting items. #[inline] - pub fn format_with_items<'a, I>(&'a self, items: I) -> DelayedFormat<'a, I> + pub fn format_with_items<'a, I>(&self, items: I) -> DelayedFormat where I: Iterator> + Clone { DelayedFormat::new(None, Some(self.clone()), items) } @@ -136,7 +136,7 @@ impl NaiveTime { /// Formats the time with the specified format string. /// See the `format::strftime` module on the supported escape sequences. #[inline] - pub fn format<'a>(&'a self, fmt: &'a str) -> DelayedFormat<'a, StrftimeItems<'a>> { + pub fn format<'a>(&self, fmt: &'a str) -> DelayedFormat> { self.format_with_items(StrftimeItems::new(fmt)) } @@ -187,8 +187,11 @@ impl Timelike for NaiveTime { } } -impl hash::Hash for NaiveTime { - fn hash(&self, state: &mut H) { self.secs.hash(state); self.frac.hash(state) } +impl hash::Hash for NaiveTime { + fn hash(&self, state: &mut H) { + self.secs.hash(state); + self.frac.hash(state); + } } impl Add for NaiveTime {