traiter/collections/
slice.rs

1use core::slice::{Iter, IterMut};
2
3use super::traits::{
4    Emptiable, Iterable, Lengthsome, MutablyIterable, ValueContainer,
5};
6
7impl<Element> Emptiable for &[Element] {
8    fn is_empty(self) -> bool {
9        <[Element]>::is_empty(self)
10    }
11}
12
13impl<Element> Emptiable for &mut [Element] {
14    fn is_empty(self) -> bool {
15        <[Element]>::is_empty(self)
16    }
17}
18
19impl<'a, Element> Iterable for &'a [Element] {
20    type Item = &'a Element;
21    type Output = Iter<'a, Element>;
22
23    fn iter(self) -> Self::Output {
24        <[Element]>::iter(self)
25    }
26}
27
28impl<'a, Element> Iterable for &'a mut [Element] {
29    type Item = &'a Element;
30    type Output = Iter<'a, Element>;
31
32    fn iter(self) -> Self::Output {
33        <[Element]>::iter(self)
34    }
35}
36
37impl<Element> Lengthsome for &[Element] {
38    type Length = usize;
39
40    fn len(self) -> Self::Length {
41        <[Element]>::len(self)
42    }
43}
44
45impl<Element> Lengthsome for &mut [Element] {
46    type Length = usize;
47
48    fn len(self) -> Self::Length {
49        <[Element]>::len(self)
50    }
51}
52
53impl<'a, Element> MutablyIterable for &'a mut [Element] {
54    type Item = &'a mut Element;
55    type Output = IterMut<'a, Element>;
56
57    fn iter_mut(self) -> Self::Output {
58        <[Element]>::iter_mut(self)
59    }
60}
61
62impl<'a, Element: PartialEq> ValueContainer for &'a [Element] {
63    type Value = &'a Element;
64
65    fn contains_value(self, value: Self::Value) -> bool {
66        <[Element]>::contains(self, value)
67    }
68}
69
70impl<'a, Element: PartialEq> ValueContainer for &'a mut [Element] {
71    type Value = &'a Element;
72
73    fn contains_value(self, value: Self::Value) -> bool {
74        <[Element]>::contains(self, value)
75    }
76}