0.2.9: language changes.
- `std::num::Int` is deprecated. - Removed one feature flag (`str_char`).
This commit is contained in:
parent
e012702033
commit
9ed34ec542
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "chrono"
|
||||
version = "0.2.8"
|
||||
version = "0.2.9"
|
||||
authors = ["Kang Seonghoon <public+rust@mearie.org>"]
|
||||
|
||||
description = "Date and time library for Rust"
|
||||
|
@ -15,5 +15,5 @@ license = "MIT/Apache-2.0"
|
|||
name = "chrono"
|
||||
|
||||
[dependencies]
|
||||
time = "0.1.22"
|
||||
time = "*"
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[Chrono][doc] 0.2.8
|
||||
[Chrono][doc] 0.2.9
|
||||
===================
|
||||
|
||||
[![Chrono on Travis CI][travis-image]][travis]
|
||||
|
|
22
src/div.rs
22
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<T: Int>(a: T, b: T) -> (T, T) {
|
||||
pub fn div_rem<T>(a: T, b: T) -> (T, T)
|
||||
where T: Copy + Div<T,Output=T> + Rem<T,Output=T> {
|
||||
(a / b, a % b)
|
||||
}
|
||||
|
||||
/// Calculates a floored integer quotient.
|
||||
#[inline]
|
||||
pub fn div_floor<T: Int>(a: T, b: T) -> T {
|
||||
pub fn div_floor<T>(a: T, b: T) -> T
|
||||
where T: Copy + Ord + Zero + One +
|
||||
Add<T,Output=T> + Sub<T,Output=T> + Div<T,Output=T> + Rem<T,Output=T> {
|
||||
div_mod_floor(a, b).0
|
||||
}
|
||||
|
||||
/// Calculates a floored modulo.
|
||||
#[inline]
|
||||
pub fn mod_floor<T: Int>(a: T, b: T) -> T {
|
||||
pub fn mod_floor<T>(a: T, b: T) -> T
|
||||
where T: Copy + Ord + Zero + One +
|
||||
Add<T,Output=T> + Sub<T,Output=T> + Div<T,Output=T> + Rem<T,Output=T> {
|
||||
div_mod_floor(a, b).1
|
||||
}
|
||||
|
||||
/// Calculates a floored integer quotient and modulo.
|
||||
#[inline]
|
||||
pub fn div_mod_floor<T: Int>(a: T, b: T) -> (T, T) {
|
||||
let zero = Int::zero();
|
||||
let one = Int::one();
|
||||
pub fn div_mod_floor<T>(a: T, b: T) -> (T, T)
|
||||
where T: Copy + Ord + Zero + One +
|
||||
Add<T,Output=T> + Sub<T,Output=T> + Div<T,Output=T> + Rem<T,Output=T> {
|
||||
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),
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
use std::usize;
|
||||
use std::num::Int;
|
||||
|
||||
use Weekday;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
use std::iter;
|
||||
use std::num::Int;
|
||||
|
||||
use Weekday;
|
||||
use super::{ParseResult, TOO_SHORT, INVALID, OUT_OF_RANGE};
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)]
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
*/
|
||||
|
||||
use std::{str, fmt, hash};
|
||||
use std::num::Int;
|
||||
use std::ops::{Add, Sub};
|
||||
|
||||
use Timelike;
|
||||
|
|
Loading…
Reference in New Issue