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() {
44 println ! ( "cargo:rustc-cfg=has_int_exp_fmt" ) ;
55 }
66
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+
716 autocfg:: rerun_path ( file ! ( ) ) ;
817}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use std::convert::TryFrom;
44macro_rules! impl_try_from {
55 ( $( $name: ty) ,* => $into: ty ; $approx: ident) => {
66 $(
7+ #[ cfg( has_try_from) ]
78 impl TryFrom <$name> for Ratio <$into> {
89 type Error = ( ) ;
910 paste:: paste! {
@@ -16,13 +17,15 @@ macro_rules! impl_try_from {
1617 }
1718 ) *
1819
20+ #[ cfg( has_try_from) ]
1921 impl TryFrom <f32 > for Ratio <$into> {
2022 type Error = ( ) ;
2123 fn try_from( n: f32 ) -> Result <Self , ( ) > {
2224 $approx( n, 10e-20 , 30 ) . ok_or( ( ) )
2325 }
2426 }
2527
28+ #[ cfg( has_try_from) ]
2629 impl TryFrom <f64 > for Ratio <$into> {
2730 type Error = ( ) ;
2831 fn try_from( n: f64 ) -> Result <Self , ( ) > {
You can’t perform that action at this time.
0 commit comments