File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1313#![ feature( const_ptr_read) ]
1414#![ feature( const_ptr_write) ]
1515#![ feature( const_ptr_offset) ]
16+ #![ feature( const_trait_impl) ]
17+ #![ feature( const_num_from_num) ]
1618#![ feature( core_intrinsics) ]
1719#![ feature( core_private_bignum) ]
1820#![ feature( core_private_diy_float) ]
Original file line number Diff line number Diff line change 1+ #[ test]
2+ fn from ( ) {
3+ use core:: convert:: TryFrom ;
4+ use core:: num:: TryFromIntError ;
5+
6+ // From
7+ const FROM : i64 = i64:: from ( 1i32 ) ;
8+ assert_eq ! ( FROM , 1i64 ) ;
9+
10+ // Upper bounded
11+ const U8_FROM_U16 : Result < u8 , TryFromIntError > = u8:: try_from ( 1u16 ) ;
12+ assert_eq ! ( U8_FROM_U16 , Ok ( 1u8 ) ) ;
13+
14+ // Both bounded
15+ const I8_FROM_I16 : Result < i8 , TryFromIntError > = i8:: try_from ( 1i16 ) ;
16+ assert_eq ! ( I8_FROM_I16 , Ok ( 1i8 ) ) ;
17+
18+ // Lower bounded
19+ const I16_FROM_U16 : Result < i16 , TryFromIntError > = i16:: try_from ( 1u16 ) ;
20+ assert_eq ! ( I16_FROM_U16 , Ok ( 1i16 ) ) ;
21+ }
Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ mod u64;
2727mod u8;
2828
2929mod bignum;
30+
31+ mod const_from;
3032mod dec2flt;
3133mod flt2dec;
3234mod int_log;
You can’t perform that action at this time.
0 commit comments