orx_iterable/sources/
empty.rs1use crate::{Collection, CollectionMut, Iterable};
2use core::marker::PhantomData;
3
4pub struct Empty<T> {
6 phantom: PhantomData<T>,
7}
8
9impl<T> Iterable for Empty<T> {
10 type Item = T;
11
12 type Iter = core::iter::Empty<T>;
13
14 fn iter(&self) -> Self::Iter {
15 Default::default()
16 }
17}
18
19impl<T> Iterable for core::iter::Empty<T> {
20 type Item = T;
21
22 type Iter = core::iter::Empty<T>;
23
24 fn iter(&self) -> Self::Iter {
25 Default::default()
26 }
27}
28
29pub struct EmptyCol<T> {
33 phantom: PhantomData<T>,
34}
35
36impl<'a, T> Iterable for &'a EmptyCol<T> {
37 type Item = &'a T;
38
39 type Iter = core::iter::Empty<Self::Item>;
40
41 fn iter(&self) -> Self::Iter {
42 Default::default()
43 }
44}
45
46impl<T> Collection for EmptyCol<T> {
47 type Item = T;
48
49 type Iterable<'i>
50 = &'i Self
51 where
52 Self: 'i;
53
54 fn as_iterable(&self) -> Self::Iterable<'_> {
55 self
56 }
57}
58
59impl<T> CollectionMut for EmptyCol<T> {
60 type IterMut<'i>
61 = core::iter::Empty<&'i mut T>
62 where
63 Self: 'i;
64
65 fn iter_mut(&mut self) -> Self::IterMut<'_> {
66 Default::default()
67 }
68}
69
70pub fn empty<T>() -> Empty<T> {
72 Empty {
73 phantom: PhantomData,
74 }
75}
76
77pub fn empty_col<T>() -> EmptyCol<T> {
79 EmptyCol {
80 phantom: PhantomData,
81 }
82}