@@ -134,6 +134,15 @@ fn test_infallible_try_from_int_error() {
134134}
135135
136136macro_rules! test_impl_from {
137+ ( $fn_name: ident, bool , $target: ty) => {
138+ #[ test]
139+ fn $fn_name( ) {
140+ let one: $target = 1 ;
141+ let zero: $target = 0 ;
142+ assert_eq!( one, <$target>:: from( true ) ) ;
143+ assert_eq!( zero, <$target>:: from( false ) ) ;
144+ }
145+ } ;
137146 ( $fn_name: ident, $Small: ty, $Large: ty) => {
138147 #[ test]
139148 fn $fn_name( ) {
@@ -173,6 +182,18 @@ test_impl_from! { test_u16i32, u16, i32 }
173182test_impl_from ! { test_u16i64, u16 , i64 }
174183test_impl_from ! { test_u32i64, u32 , i64 }
175184
185+ // Bool -> Integer
186+ test_impl_from ! { test_boolu8, bool , u8 }
187+ test_impl_from ! { test_boolu16, bool , u16 }
188+ test_impl_from ! { test_boolu32, bool , u32 }
189+ test_impl_from ! { test_boolu64, bool , u64 }
190+ test_impl_from ! { test_boolu128, bool , u128 }
191+ test_impl_from ! { test_booli8, bool , i8 }
192+ test_impl_from ! { test_booli16, bool , i16 }
193+ test_impl_from ! { test_booli32, bool , i32 }
194+ test_impl_from ! { test_booli64, bool , i64 }
195+ test_impl_from ! { test_booli128, bool , i128 }
196+
176197// Signed -> Float
177198test_impl_from ! { test_i8f32, i8 , f32 }
178199test_impl_from ! { test_i8f64, i8 , f64 }
0 commit comments