diff --git a/build.rs b/build.rs index 4dcf8e8..4f39b83 100644 --- a/build.rs +++ b/build.rs @@ -1,18 +1,19 @@ extern crate autocfg; -use autocfg::AutoCfg; use std::env; fn main() { + let autocfg = autocfg::new(); + // If the "i128" feature is explicity requested, don't bother probing for it. // It will still cause a build error if that was set improperly. - if env::var_os("CARGO_FEATURE_I128").is_some() || autocfg::new().probe_type("i128") { + if env::var_os("CARGO_FEATURE_I128").is_some() || autocfg.probe_type("i128") { autocfg::emit("has_i128"); } // The RangeBounds trait was stabilized in 1.28, so from that version onwards we // implement that trait. - AutoCfg::new().unwrap().emit_rustc_version(1, 28); + autocfg.emit_rustc_version(1, 28); autocfg::rerun_path("build.rs"); } diff --git a/src/lib.rs b/src/lib.rs index 58ce531..1689dee 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,11 +22,14 @@ extern crate std; extern crate num_integer as integer; extern crate num_traits as traits; -use core::ops::{Add, Bound, RangeBounds, Sub}; +use core::ops::{Add, Sub}; use core::usize; use integer::Integer; use traits::{CheckedAdd, One, ToPrimitive, Zero}; +#[cfg(rustc_1_28)] +use core::ops::{Bound, RangeBounds}; + /// An iterator over the range [start, stop) #[derive(Clone)] pub struct Range { @@ -250,17 +253,6 @@ pub struct RangeStep { rev: bool, } -#[cfg(rustc_1_28)] -impl RangeBounds for RangeStep { - fn start_bound(&self) -> Bound<&A> { - Bound::Included(&self.state) - } - - fn end_bound(&self) -> Bound<&A> { - Bound::Excluded(&self.stop) - } -} - /// Return an iterator over the range [start, stop) by `step`. It handles overflow by stopping. #[inline] pub fn range_step(start: A, stop: A, step: A) -> RangeStep @@ -323,17 +315,6 @@ where } } -#[cfg(rustc_1_28)] -impl RangeBounds for RangeStepInclusive { - fn start_bound(&self) -> Bound<&A> { - Bound::Included(&self.state) - } - - fn end_bound(&self) -> Bound<&A> { - Bound::Included(&self.stop) - } -} - impl Iterator for RangeStepInclusive where A: CheckedAdd + PartialOrd + Clone + PartialEq, @@ -435,17 +416,6 @@ where } } -#[cfg(rustc_1_28)] -impl RangeBounds for RangeStepFrom { - fn start_bound(&self) -> Bound<&A> { - Bound::Included(&self.state) - } - - fn end_bound(&self) -> Bound<&A> { - Bound::Unbounded - } -} - impl Iterator for RangeStepFrom where A: Add + Clone,