From 9ed34ec5429350bea862173f62b060c30707b82a Mon Sep 17 00:00:00 2001 From: Kang Seonghoon Date: Fri, 3 Apr 2015 17:53:44 +0900 Subject: [PATCH] 0.2.9: language changes. - `std::num::Int` is deprecated. - Removed one feature flag (`str_char`). --- Cargo.toml | 4 ++-- README.md | 2 +- src/div.rs | 22 +++++++++++++++------- src/format/parse.rs | 1 - src/format/scan.rs | 1 - src/format/strftime.rs | 12 ++++++------ src/lib.rs | 4 ++-- src/naive/time.rs | 1 - 8 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 63ba684..f3bf079 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "chrono" -version = "0.2.8" +version = "0.2.9" authors = ["Kang Seonghoon "] description = "Date and time library for Rust" @@ -15,5 +15,5 @@ license = "MIT/Apache-2.0" name = "chrono" [dependencies] -time = "0.1.22" +time = "*" diff --git a/README.md b/README.md index 6396e44..7ba3443 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[Chrono][doc] 0.2.8 +[Chrono][doc] 0.2.9 =================== [![Chrono on Travis CI][travis-image]][travis] diff --git a/src/div.rs b/src/div.rs index d04933a..693460b 100644 --- a/src/div.rs +++ b/src/div.rs @@ -8,31 +8,39 @@ // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) -use std::num::Int; +use std::ops::{Add, Sub, Div, Rem}; +use std::num::{Zero, One}; /// Same as `(a / b, a % b)`. #[inline] -pub fn div_rem(a: T, b: T) -> (T, T) { +pub fn div_rem(a: T, b: T) -> (T, T) + where T: Copy + Div + Rem { (a / b, a % b) } /// Calculates a floored integer quotient. #[inline] -pub fn div_floor(a: T, b: T) -> T { +pub fn div_floor(a: T, b: T) -> T + where T: Copy + Ord + Zero + One + + Add + Sub + Div + Rem { div_mod_floor(a, b).0 } /// Calculates a floored modulo. #[inline] -pub fn mod_floor(a: T, b: T) -> T { +pub fn mod_floor(a: T, b: T) -> T + where T: Copy + Ord + Zero + One + + Add + Sub + Div + Rem { div_mod_floor(a, b).1 } /// Calculates a floored integer quotient and modulo. #[inline] -pub fn div_mod_floor(a: T, b: T) -> (T, T) { - let zero = Int::zero(); - let one = Int::one(); +pub fn div_mod_floor(a: T, b: T) -> (T, T) + where T: Copy + Ord + Zero + One + + Add + Sub + Div + Rem { + let zero = Zero::zero(); + let one = One::one(); match (a / b, a % b) { (d, r) if (r > zero && b < zero) || (r < zero && b > zero) => (d - one, r + b), (d, r) => (d, r), diff --git a/src/format/parse.rs b/src/format/parse.rs index ceb21b9..cfe75ce 100644 --- a/src/format/parse.rs +++ b/src/format/parse.rs @@ -8,7 +8,6 @@ */ use std::usize; -use std::num::Int; use Weekday; diff --git a/src/format/scan.rs b/src/format/scan.rs index b3f4d7f..c62efdc 100644 --- a/src/format/scan.rs +++ b/src/format/scan.rs @@ -7,7 +7,6 @@ */ use std::iter; -use std::num::Int; use Weekday; use super::{ParseResult, TOO_SHORT, INVALID, OUT_OF_RANGE}; diff --git a/src/format/strftime.rs b/src/format/strftime.rs index 7d6f355..1f5c38d 100644 --- a/src/format/strftime.rs +++ b/src/format/strftime.rs @@ -134,19 +134,19 @@ impl<'a> Iterator for StrftimeItems<'a> { return Some(item); } - match self.remainder.slice_shift_char() { + match self.remainder.chars().next() { // we are done None => return None, // the next item is a specifier - Some(('%', remainder)) => { - self.remainder = remainder; + Some('%') => { + self.remainder = &self.remainder[1..]; - let (spec, remainder) = match self.remainder.slice_shift_char() { + let spec = match self.remainder.chars().next() { Some(x) => x, None => return Some(Item::Error), // premature end of string }; - self.remainder = remainder; + self.remainder = &self.remainder[spec.len_utf8()..]; macro_rules! recons { [$head:expr, $($tail:expr),+] => ({ @@ -216,7 +216,7 @@ impl<'a> Iterator for StrftimeItems<'a> { }, // the next item is space - Some((c, _)) if c.is_whitespace() => { + Some(c) if c.is_whitespace() => { // `%` is not a whitespace, so `c != '%'` is redundant let nextspec = self.remainder.find(|c: char| !c.is_whitespace()) .unwrap_or(self.remainder.len()); diff --git a/src/lib.rs b/src/lib.rs index bfa3e4f..3c49cfc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ /*! -# Chrono 0.2.8 +# Chrono 0.2.9 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. @@ -268,7 +268,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(slice_patterns)] -#![feature(core, str_char, std_misc)] // lib stability features as per RFC #507 +#![feature(core, std_misc, zero_one)] // lib stability features as per RFC #507 #![cfg_attr(test, feature(test))] // ditto #![deny(missing_docs)] diff --git a/src/naive/time.rs b/src/naive/time.rs index 26fb168..1c31b77 100644 --- a/src/naive/time.rs +++ b/src/naive/time.rs @@ -7,7 +7,6 @@ */ use std::{str, fmt, hash}; -use std::num::Int; use std::ops::{Add, Sub}; use Timelike;