diff --git a/src/div.rs b/src/div.rs index 693460b..718c3a1 100644 --- a/src/div.rs +++ b/src/div.rs @@ -8,44 +8,7 @@ // Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_, // December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf) -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) - where T: Copy + Div + Rem { - (a / b, a % b) -} - -/// Calculates a floored integer quotient. -#[inline] -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 - 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) - 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), - } -} +pub use num::integer::{div_rem, div_floor, mod_floor, div_mod_floor}; #[cfg(test)] mod tests { diff --git a/src/lib.rs b/src/lib.rs index 98f8ac1..82b32fd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -267,7 +267,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(std_misc, zero_one)] // lib stability features as per RFC #507 +#![feature(std_misc)] // lib stability features as per RFC #507 #![cfg_attr(test, feature(test))] // ditto #![deny(missing_docs)] @@ -600,7 +600,7 @@ pub trait Timelike { #[test] fn test_readme_doomsday() { - use std::iter::range_inclusive; + use num::iter::range_inclusive; for y in range_inclusive(naive::date::MIN.year(), naive::date::MAX.year()) { // even months diff --git a/src/naive/date.rs b/src/naive/date.rs index 6531fd9..6374d85 100644 --- a/src/naive/date.rs +++ b/src/naive/date.rs @@ -1495,7 +1495,7 @@ mod internals { use Weekday; use super::{Of, Mdf}; use super::{YearFlags, A, B, C, D, E, F, G, AG, BA, CB, DC, ED, FE, GF}; - use std::iter::range_inclusive; + use num::iter::range_inclusive; use std::u32; const NONLEAP_FLAGS: [YearFlags; 7] = [A, B, C, D, E, F, G];