diff --git a/build.rs b/build.rs index 37c9857..4dcf8e8 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,6 @@ extern crate autocfg; +use autocfg::AutoCfg; use std::env; fn main() { @@ -9,5 +10,9 @@ fn main() { 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::rerun_path("build.rs"); } diff --git a/src/lib.rs b/src/lib.rs index 97b232e..58ce531 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -84,6 +84,7 @@ fn unsigned(x: &T) -> Option { } } +#[cfg(rustc_1_28)] impl RangeBounds for Range { fn start_bound(&self) -> Bound<&A> { Bound::Included(&self.state) @@ -173,6 +174,7 @@ where } } +#[cfg(rustc_1_28)] impl RangeBounds for RangeInclusive { fn start_bound(&self) -> Bound<&A> { Bound::Included(&self.range.state) @@ -248,6 +250,7 @@ pub struct RangeStep { rev: bool, } +#[cfg(rustc_1_28)] impl RangeBounds for RangeStep { fn start_bound(&self) -> Bound<&A> { Bound::Included(&self.state) @@ -320,6 +323,7 @@ where } } +#[cfg(rustc_1_28)] impl RangeBounds for RangeStepInclusive { fn start_bound(&self) -> Bound<&A> { Bound::Included(&self.state) @@ -377,6 +381,7 @@ where } } +#[cfg(rustc_1_28)] impl RangeBounds for RangeFrom { fn start_bound(&self) -> Bound<&A> { Bound::Included(&self.state) @@ -430,6 +435,7 @@ where } } +#[cfg(rustc_1_28)] impl RangeBounds for RangeStepFrom { fn start_bound(&self) -> Bound<&A> { Bound::Included(&self.state)