File tree Expand file tree Collapse file tree 4 files changed +44
-5
lines changed Expand file tree Collapse file tree 4 files changed +44
-5
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,13 @@ repository = "https://github.com/rust-num/num-integer"
10
10
name = " num-integer"
11
11
version = " 0.1.37"
12
12
readme = " README.md"
13
+ build = " build.rs"
13
14
14
15
[package .metadata .docs .rs ]
15
- all- features = true
16
+ features = [ " std " ]
16
17
17
18
[dependencies .num-traits ]
18
- version = " 0.2.3 "
19
+ version = " 0.2.4 "
19
20
default-features = false
20
21
21
22
[features ]
Original file line number Diff line number Diff line change @@ -36,7 +36,10 @@ default-features = false
36
36
There is no functional difference with and without ` std ` at this time, but
37
37
there may be in the future.
38
38
39
- Implementations for ` i128 ` and ` u128 ` are only available when ` i128 ` is enabled.
39
+ Implementations for ` i128 ` and ` u128 ` are only available with Rust 1.26 and
40
+ later. The build script automatically detects this, but you can make it
41
+ mandatory by enabling the ` i128 ` crate feature.
42
+
40
43
41
44
## Releases
42
45
Original file line number Diff line number Diff line change
1
+ use std:: env;
2
+ use std:: io:: Write ;
3
+ use std:: process:: { Command , Stdio } ;
4
+
5
+ fn main ( ) {
6
+ if probe ( "fn main() { 0i128; }" ) {
7
+ println ! ( "cargo:rustc-cfg=has_i128" ) ;
8
+ } else if env:: var_os ( "CARGO_FEATURE_I128" ) . is_some ( ) {
9
+ panic ! ( "i128 support was not detected!" ) ;
10
+ }
11
+ }
12
+
13
+ /// Test if a code snippet can be compiled
14
+ fn probe ( code : & str ) -> bool {
15
+ let rustc = env:: var_os ( "RUSTC" ) . unwrap_or_else ( || "rustc" . into ( ) ) ;
16
+ let out_dir = env:: var_os ( "OUT_DIR" ) . expect ( "environment variable OUT_DIR" ) ;
17
+
18
+ let mut child = Command :: new ( rustc)
19
+ . arg ( "--out-dir" )
20
+ . arg ( out_dir)
21
+ . arg ( "--emit=obj" )
22
+ . arg ( "-" )
23
+ . stdin ( Stdio :: piped ( ) )
24
+ . spawn ( )
25
+ . expect ( "rustc probe" ) ;
26
+
27
+ child
28
+ . stdin
29
+ . as_mut ( )
30
+ . expect ( "rustc stdin" )
31
+ . write_all ( code. as_bytes ( ) )
32
+ . expect ( "write rustc stdin" ) ;
33
+
34
+ child. wait ( ) . expect ( "rustc probe" ) . success ( )
35
+ }
Original file line number Diff line number Diff line change @@ -503,7 +503,7 @@ impl_integer_for_isize!(i16, test_integer_i16);
503
503
impl_integer_for_isize ! ( i32 , test_integer_i32) ;
504
504
impl_integer_for_isize ! ( i64 , test_integer_i64) ;
505
505
impl_integer_for_isize ! ( isize , test_integer_isize) ;
506
- #[ cfg( feature = "i128" ) ]
506
+ #[ cfg( has_i128 ) ]
507
507
impl_integer_for_isize ! ( i128 , test_integer_i128) ;
508
508
509
509
macro_rules! impl_integer_for_usize {
@@ -677,7 +677,7 @@ impl_integer_for_usize!(u16, test_integer_u16);
677
677
impl_integer_for_usize ! ( u32 , test_integer_u32) ;
678
678
impl_integer_for_usize ! ( u64 , test_integer_u64) ;
679
679
impl_integer_for_usize ! ( usize , test_integer_usize) ;
680
- #[ cfg( feature = "i128" ) ]
680
+ #[ cfg( has_i128 ) ]
681
681
impl_integer_for_usize ! ( u128 , test_integer_u128) ;
682
682
683
683
/// An iterator over binomial coefficients.
You can’t perform that action at this time.
0 commit comments