fixed_map/
macro_support.rs1#![allow(clippy::missing_inline_in_public_items)]
8
9use core::cmp::Ordering;
10
11#[inline]
12fn flatten<T>(value: (usize, &Option<T>)) -> Option<(usize, &T)> {
13 match value {
14 (index, Some(value)) => Some((index, value)),
15 _ => None,
16 }
17}
18
19pub fn __storage_iterator_partial_cmp<'a, A, B, T: 'a>(a: A, b: B) -> Option<Ordering>
22where
23 A: IntoIterator<Item = &'a Option<T>>,
24 B: IntoIterator<Item = &'a Option<T>>,
25 T: PartialOrd<T>,
26{
27 let a = a.into_iter().enumerate().filter_map(flatten);
28 let b = b.into_iter().enumerate().filter_map(flatten);
29 a.partial_cmp(b)
30}
31
32pub fn __storage_iterator_cmp<'a, A, B, T: 'a>(a: A, b: B) -> Ordering
35where
36 A: IntoIterator<Item = &'a Option<T>>,
37 B: IntoIterator<Item = &'a Option<T>>,
38 T: Ord,
39{
40 let a = a.into_iter().enumerate().filter_map(flatten);
41 let b = b.into_iter().enumerate().filter_map(flatten);
42 a.cmp(b)
43}
44
45#[inline]
46fn filter_bool(&(_, value): &(usize, &bool)) -> bool {
47 *value
48}
49
50pub fn __storage_iterator_partial_cmp_bool<'a, A, B>(a: A, b: B) -> Option<Ordering>
53where
54 A: IntoIterator<Item = &'a bool>,
55 B: IntoIterator<Item = &'a bool>,
56{
57 let a = a.into_iter().enumerate().filter(filter_bool);
58 let b = b.into_iter().enumerate().filter(filter_bool);
59 a.partial_cmp(b)
60}
61
62pub fn __storage_iterator_cmp_bool<'a, A, B>(a: A, b: B) -> Ordering
65where
66 A: IntoIterator<Item = &'a bool>,
67 B: IntoIterator<Item = &'a bool>,
68{
69 let a = a.into_iter().enumerate().filter(filter_bool);
70 let b = b.into_iter().enumerate().filter(filter_bool);
71 a.cmp(b)
72}