| 3 */ |
3 */ |
| 4 |
4 |
| 5 use crate::loc::Loc; |
5 use crate::loc::Loc; |
| 6 |
6 |
| 7 /// An abstract collection of elements. |
7 /// An abstract collection of elements. |
| 8 pub trait Collection : IntoIterator<Item = Self::Element> { |
8 pub trait Collection: IntoIterator<Item = Self::Element> { |
| 9 /// Type of elements of the collection |
9 /// Type of elements of the collection |
| 10 type Element; |
10 type Element; |
| 11 /// Iterator over references to elements of the collection |
11 /// Iterator over references to elements of the collection |
| 12 type RefsIter<'a> : Iterator<Item=&'a Self::Element> where Self : 'a; |
12 type RefsIter<'a>: Iterator<Item = &'a Self::Element> |
| |
13 where |
| |
14 Self: 'a; |
| 13 |
15 |
| 14 /// Returns an iterator over references to elements of the collection. |
16 /// Returns an iterator over references to elements of the collection. |
| 15 fn iter_refs(&self) -> Self::RefsIter<'_>; |
17 fn iter_refs(&self) -> Self::RefsIter<'_>; |
| 16 } |
18 } |
| 17 |
19 |
| 18 /// An abstract collection of mutable elements. |
20 /// An abstract collection of mutable elements. |
| 19 pub trait CollectionMut : Collection { |
21 pub trait CollectionMut: Collection { |
| 20 /// Iterator over references to elements of the collection |
22 /// Iterator over references to elements of the collection |
| 21 type RefsIterMut<'a> : Iterator<Item=&'a mut Self::Element> where Self : 'a; |
23 type RefsIterMut<'a>: Iterator<Item = &'a mut Self::Element> |
| |
24 where |
| |
25 Self: 'a; |
| 22 |
26 |
| 23 /// Returns an iterator over references to elements of the collection. |
27 /// Returns an iterator over references to elements of the collection. |
| 24 fn iter_refs_mut(&mut self) -> Self::RefsIterMut<'_>; |
28 fn iter_refs_mut(&mut self) -> Self::RefsIterMut<'_>; |
| 25 } |
29 } |
| 26 |
30 |