Skip to content

Commit

Permalink
Merge pull request #221 from cuviper/num-no_std
Browse files Browse the repository at this point in the history
Use no_std-compatible num dependencies
  • Loading branch information
quodlibetor authored Mar 4, 2018
2 parents 312d089 + 8f90f40 commit 2a825ed
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ name = "chrono"

[dependencies]
time = "^0.1.36"
num = { version = "0.1", default-features = false }
num-integer = { version = "0.1.36", default-features = false }
num-traits = { version = "0.2", default-features = false }
rustc-serialize = { version = "0.3", optional = true }
serde = { version = "1", optional = true }

[dev-dependencies]
serde_json = { version = "1" }
serde_derive = { version = "1" }
bincode = { version = "0.8.0" }
num-iter = { version = "0.1.35", default-features = false }

[package.metadata.docs.rs]
all-features = true
2 changes: 1 addition & 1 deletion src/div.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
// December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)

pub use num::integer::{div_rem, div_floor, mod_floor, div_mod_floor};
pub use num_integer::{div_rem, div_floor, mod_floor, div_mod_floor};

#[cfg(test)]
mod tests {
Expand Down
2 changes: 1 addition & 1 deletion src/format/parsed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! A collection of parsed date and time items.
//! They can be constructed incrementally while being checked for consistency.
use num::traits::ToPrimitive;
use num_traits::ToPrimitive;
use oldtime::Duration as OldDuration;

use {Datelike, Timelike};
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@
#![cfg_attr(feature = "cargo-clippy", allow(const_static_lifetime, redundant_field_names))]

extern crate time as oldtime;
extern crate num;
extern crate num_integer;
extern crate num_traits;
#[cfg(feature = "rustc-serialize")]
extern crate rustc_serialize;
#[cfg(feature = "serde")]
Expand Down Expand Up @@ -618,7 +619,7 @@ impl Weekday {
/// Any weekday can be represented as an integer from 0 to 6, which equals to
/// [`Weekday::num_days_from_monday`](#method.num_days_from_monday) in this implementation.
/// Do not heavily depend on this though; use explicit methods whenever possible.
impl num::traits::FromPrimitive for Weekday {
impl num_traits::FromPrimitive for Weekday {
#[inline]
fn from_i64(n: i64) -> Option<Weekday> {
match n {
Expand Down Expand Up @@ -933,9 +934,11 @@ pub trait Timelike: Sized {
}
}

#[cfg(test)] extern crate num_iter;

#[test]
fn test_readme_doomsday() {
use num::iter::range_inclusive;
use num_iter::range_inclusive;

for y in range_inclusive(naive::MIN_DATE.year(), naive::MAX_DATE.year()) {
// even months
Expand Down
2 changes: 1 addition & 1 deletion src/naive/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::{str, fmt};
use std::ops::{Add, Sub, AddAssign, SubAssign};
use num::traits::ToPrimitive;
use num_traits::ToPrimitive;
use oldtime::Duration as OldDuration;

use {Weekday, Datelike};
Expand Down
2 changes: 1 addition & 1 deletion src/naive/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::{str, fmt, hash};
use std::ops::{Add, Sub, AddAssign, SubAssign};
use num::traits::ToPrimitive;
use num_traits::ToPrimitive;
use oldtime::Duration as OldDuration;

use {Weekday, Timelike, Datelike};
Expand Down
5 changes: 3 additions & 2 deletions src/naive/internals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#![allow(dead_code)] // some internal methods have been left for consistency

use std::{i32, fmt};
use num::traits::FromPrimitive;
use num_traits::FromPrimitive;
use Weekday;
use div::{div_rem, mod_floor};

Expand Down Expand Up @@ -469,12 +469,13 @@ impl fmt::Debug for Mdf {

#[cfg(test)]
mod tests {
#[cfg(test)] extern crate num_iter;
#[cfg(bench)] extern crate test;

use Weekday;
use super::{Of, Mdf};
use super::{YearFlags, A, B, C, D, E, F, G, AG, BA, CB, DC, ED, FE, GF};
use num::iter::range_inclusive;
use num_iter::range_inclusive;
use std::u32;

const NONLEAP_FLAGS: [YearFlags; 7] = [A, B, C, D, E, F, G];
Expand Down

0 comments on commit 2a825ed

Please sign in to comment.