File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -4,5 +4,14 @@ fn main() {
4
4
println ! ( "cargo:rustc-cfg=has_int_exp_fmt" ) ;
5
5
}
6
6
7
+ let std = if ac. probe_sysroot_crate ( "std" ) {
8
+ "std"
9
+ } else {
10
+ "core"
11
+ } ;
12
+ if ac. probe_path ( & format ! ( "{}::convert::TryFrom" , std) ) {
13
+ autocfg:: emit ( "has_try_from" ) ;
14
+ }
15
+
7
16
autocfg:: rerun_path ( file ! ( ) ) ;
8
17
}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use std::convert::TryFrom;
4
4
macro_rules! impl_try_from {
5
5
( $( $name: ty) ,* => $into: ty ; $approx: ident) => {
6
6
$(
7
+ #[ cfg( has_try_from) ]
7
8
impl TryFrom <$name> for Ratio <$into> {
8
9
type Error = ( ) ;
9
10
paste:: paste! {
@@ -16,13 +17,15 @@ macro_rules! impl_try_from {
16
17
}
17
18
) *
18
19
20
+ #[ cfg( has_try_from) ]
19
21
impl TryFrom <f32 > for Ratio <$into> {
20
22
type Error = ( ) ;
21
23
fn try_from( n: f32 ) -> Result <Self , ( ) > {
22
24
$approx( n, 10e-20 , 30 ) . ok_or( ( ) )
23
25
}
24
26
}
25
27
28
+ #[ cfg( has_try_from) ]
26
29
impl TryFrom <f64 > for Ratio <$into> {
27
30
type Error = ( ) ;
28
31
fn try_from( n: f64 ) -> Result <Self , ( ) > {
You can’t perform that action at this time.
0 commit comments