0.2.1: language changes.

- `std::hash` has been renewed.

- `DelayedFormat` no longer has a redundant lifetime.
This commit is contained in:
Kang Seonghoon 2015-02-21 18:14:09 +09:00
parent e80501dcb3
commit c11b6deb5a
10 changed files with 43 additions and 31 deletions

View File

@ -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

View File

@ -1,6 +1,6 @@
[package]
name = "chrono"
version = "0.2.0"
version = "0.2.1"
authors = ["Kang Seonghoon <public+rust@mearie.org>"]
description = "Date and time library for Rust"

View File

@ -1,4 +1,4 @@
[Chrono][doc] 0.2.0
[Chrono][doc] 0.2.1
===================
[![Chrono on Travis CI][travis-image]][travis]

View File

@ -224,7 +224,7 @@ fn map_local<Tz: TimeZone, F>(d: &Date<Tz>, mut f: F) -> Option<Date<Tz>>
impl<Tz: TimeZone> Date<Tz> 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<I>
where I: Iterator<Item=Item<'a>> + Clone {
DelayedFormat::new_with_offset(Some(self.naive_local()), None, &self.offset, items)
}
@ -232,7 +232,7 @@ impl<Tz: TimeZone> Date<Tz> 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<StrftimeItems<'a>> {
self.format_with_items(StrftimeItems::new(fmt))
}
}
@ -301,8 +301,8 @@ impl<Tz: TimeZone> Ord for Date<Tz> {
fn cmp(&self, other: &Date<Tz>) -> Ordering { self.date.cmp(&other.date) }
}
impl<Tz: TimeZone, H: hash::Hasher + hash::Writer> hash::Hash<H> for Date<Tz> {
fn hash(&self, state: &mut H) { self.date.hash(state) }
impl<Tz: TimeZone> hash::Hash for Date<Tz> {
fn hash<H: hash::Hasher>(&self, state: &mut H) { self.date.hash(state) }
}
impl<Tz: TimeZone> Add<Duration> for Date<Tz> {

View File

@ -171,7 +171,7 @@ impl<Tz: TimeZone> DateTime<Tz> 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<I>
where I: Iterator<Item=Item<'a>> + Clone {
let local = self.naive_local();
DelayedFormat::new_with_offset(Some(local.date()), Some(local.time()), &self.offset, items)
@ -180,7 +180,7 @@ impl<Tz: TimeZone> DateTime<Tz> 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<StrftimeItems<'a>> {
self.format_with_items(StrftimeItems::new(fmt))
}
}
@ -276,8 +276,8 @@ impl<Tz: TimeZone> Ord for DateTime<Tz> {
fn cmp(&self, other: &DateTime<Tz>) -> Ordering { self.datetime.cmp(&other.datetime) }
}
impl<Tz: TimeZone, H: hash::Hasher + hash::Writer> hash::Hash<H> for DateTime<Tz> {
fn hash(&self, state: &mut H) { self.datetime.hash(state) }
impl<Tz: TimeZone> hash::Hash for DateTime<Tz> {
fn hash<H: hash::Hasher>(&self, state: &mut H) { self.datetime.hash(state) }
}
impl<Tz: TimeZone> Add<Duration> for DateTime<Tz> {

View File

@ -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<Item=Item<'a>> + Clone> {
pub struct DelayedFormat<I> {
/// The date view, if any.
date: Option<NaiveDate>,
/// The time view, if any.
@ -421,22 +421,22 @@ pub struct DelayedFormat<'a, I: Iterator<Item=Item<'a>> + Clone> {
items: I,
}
impl<'a, I: Iterator<Item=Item<'a>> + Clone> DelayedFormat<'a, I> {
impl<'a, I: Iterator<Item=Item<'a>> + Clone> DelayedFormat<I> {
/// Makes a new `DelayedFormat` value out of local date and time.
pub fn new(date: Option<NaiveDate>, time: Option<NaiveTime>, items: I) -> DelayedFormat<'a, I> {
pub fn new(date: Option<NaiveDate>, time: Option<NaiveTime>, items: I) -> DelayedFormat<I> {
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<Off>(date: Option<NaiveDate>, time: Option<NaiveTime>,
offset: &Off, items: I) -> DelayedFormat<'a, I>
offset: &Off, items: I) -> DelayedFormat<I>
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<Item=Item<'a>> + Clone> fmt::Display for DelayedFormat<'a, I> {
impl<'a, I: Iterator<Item=Item<'a>> + Clone> fmt::Display for DelayedFormat<I> {
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())
}

View File

@ -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)]

View File

@ -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<I>
where I: Iterator<Item=Item<'a>> + 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<StrftimeItems<'a>> {
self.format_with_items(StrftimeItems::new(fmt))
}
}
@ -452,8 +452,8 @@ impl Datelike for NaiveDate {
}
}
impl<H: hash::Hasher + hash::Writer> hash::Hash<H> for NaiveDate {
fn hash(&self, state: &mut H) { self.ymdf.hash(state) }
impl hash::Hash for NaiveDate {
fn hash<H: hash::Hasher>(&self, state: &mut H) { self.ymdf.hash(state) }
}
impl Add<Duration> 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,

View File

@ -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<I>
where I: Iterator<Item=Item<'a>> + 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<StrftimeItems<'a>> {
self.format_with_items(StrftimeItems::new(fmt))
}
}
@ -245,8 +245,11 @@ impl Timelike for NaiveDateTime {
}
}
impl<H: hash::Hasher + hash::Writer> hash::Hash<H> for NaiveDateTime {
fn hash(&self, state: &mut H) { self.date.hash(state); self.time.hash(state) }
impl hash::Hash for NaiveDateTime {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.date.hash(state);
self.time.hash(state);
}
}
impl Add<Duration> for NaiveDateTime {

View File

@ -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<I>
where I: Iterator<Item=Item<'a>> + 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<StrftimeItems<'a>> {
self.format_with_items(StrftimeItems::new(fmt))
}
@ -187,8 +187,11 @@ impl Timelike for NaiveTime {
}
}
impl<H: hash::Hasher + hash::Writer> hash::Hash<H> for NaiveTime {
fn hash(&self, state: &mut H) { self.secs.hash(state); self.frac.hash(state) }
impl hash::Hash for NaiveTime {
fn hash<H: hash::Hasher>(&self, state: &mut H) {
self.secs.hash(state);
self.frac.hash(state);
}
}
impl Add<Duration> for NaiveTime {