1 use crate::traits::{Integer, Sealed};
2 
3 pub trait int_v1_46: Integer {
leading_ones(self) -> u324     fn leading_ones(self) -> u32;
trailing_ones(self) -> u325     fn trailing_ones(self) -> u32;
6 }
7 
8 macro_rules! impl_int_v1_46 {
9     ($($signed_type:ty, $unsigned_type:ty),*) => {$(
10         impl int_v1_46 for $signed_type {
11             #[inline]
12             fn leading_ones(self) -> u32 {
13                 (self as $unsigned_type).leading_ones()
14             }
15 
16             #[inline]
17             fn trailing_ones(self) -> u32 {
18                 (self as $unsigned_type).trailing_ones()
19             }
20         }
21 
22         impl int_v1_46 for $unsigned_type {
23             #[inline]
24             fn leading_ones(self) -> u32 {
25                 (!self).leading_zeros()
26             }
27 
28             #[inline]
29             fn trailing_ones(self) -> u32 {
30                 (!self).trailing_zeros()
31             }
32         }
33     )*};
34 }
35 
36 impl_int_v1_46![
37     i8, u8, i16, u16, i32, u32, i64, u64, i128, u128, isize, usize
38 ];
39 
40 pub trait Option_v1_46<T>: Sealed<Option<T>> {
zip<U>(self, other: Option<U>) -> Option<(T, U)>41     fn zip<U>(self, other: Option<U>) -> Option<(T, U)>;
42 }
43 
44 impl<T> Option_v1_46<T> for Option<T> {
zip<U>(self, other: Option<U>) -> Option<(T, U)>45     fn zip<U>(self, other: Option<U>) -> Option<(T, U)> {
46         match (self, other) {
47             (Some(a), Some(b)) => Some((a, b)),
48             _ => None,
49         }
50     }
51 }
52