Skip to content

Commit

Permalink
Make i128/u128 support conditional on Rust 1.26. (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfishcode authored and m4b committed Sep 23, 2018
1 parent a9abfa2 commit e41442c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ description = "A suite of powerful, extensible, generic, endian-aware Read/Write
[dependencies]
scroll_derive = { version = "0.9", optional = true }

[build-dependencies]
rustc_version = "0.2"

[features]
default = ["std"]
std = []
Expand Down
8 changes: 8 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
extern crate rustc_version;
use rustc_version::{version, Version};

fn main() {
if version().unwrap() >= Version::parse("1.26.0").unwrap() {
println!("cargo:rustc-cfg=rust_1_26");
}
}
6 changes: 6 additions & 0 deletions src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ ctx_impl!(u32, 4);
ctx_impl!(i32, 4);
ctx_impl!(u64, 8);
ctx_impl!(i64, 8);
#[cfg(rust_1_26)]
ctx_impl!(u128, 16);
#[cfg(rust_1_26)]
ctx_impl!(i128, 16);

macro_rules! from_ctx_float_impl {
Expand Down Expand Up @@ -335,7 +337,9 @@ into_ctx_impl!(u32, 4);
into_ctx_impl!(i32, 4);
into_ctx_impl!(u64, 8);
into_ctx_impl!(i64, 8);
#[cfg(rust_1_26)]
into_ctx_impl!(u128, 16);
#[cfg(rust_1_26)]
into_ctx_impl!(i128, 16);

macro_rules! into_ctx_float_impl {
Expand Down Expand Up @@ -473,7 +477,9 @@ sizeof_impl!(u32);
sizeof_impl!(i32);
sizeof_impl!(u64);
sizeof_impl!(i64);
#[cfg(rust_1_26)]
sizeof_impl!(u128);
#[cfg(rust_1_26)]
sizeof_impl!(i128);
sizeof_impl!(f32);
sizeof_impl!(f64);
Expand Down

0 comments on commit e41442c

Please sign in to comment.