1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#[cfg(feature = "std")]
use std::ops;
#[cfg(not(feature = "std"))]
use core::ops;
use self::ops::{Index, IndexMut, Range, RangeFrom, RangeFull, RangeTo};
#[cfg(feature = "nightly")]
use self::ops::{RangeInclusive, RangeToInclusive};
pub trait Len {
fn len(&self) -> usize;
fn is_empty(&self) -> bool {
self.len() == 0
}
}
pub trait LenZero: Len {
fn clear(&mut self);
}
pub trait LenMut: Default + LenZero {
fn truncate(&mut self, len: usize);
}
pub trait Capacity {
fn capacity(&self) -> usize;
}
pub trait DefaultCapacity: Capacity + Default {
fn default_capacity(capacity: usize) -> Self;
}
pub trait CapacityMut: Len + DefaultCapacity {
fn reserve(&mut self, additional: usize);
fn reserve_exact(&mut self, additional: usize);
fn shrink_to_fit(&mut self);
}
#[cfg(feature = "nightly")]
pub trait IndexRanges: Index<Range<usize>, Output = Self>
+ Index<RangeTo<usize>, Output = Self>
+ Index<RangeFrom<usize>, Output = Self>
+ Index<RangeInclusive<usize>, Output = Self>
+ Index<RangeToInclusive<usize>, Output = Self>
+ Index<RangeFull, Output = Self> {}
#[cfg(feature = "nightly")]
impl<T: ?Sized> IndexRanges for T
where T: Index<Range<usize>, Output = Self>
+ Index<RangeTo<usize>, Output = Self>
+ Index<RangeFrom<usize>, Output = Self>
+ Index<RangeInclusive<usize>, Output = Self>
+ Index<RangeToInclusive<usize>, Output = Self>
+ Index<RangeFull, Output = Self>
{}
#[cfg(not(feature = "nightly"))]
pub trait IndexRanges: Index<Range<usize>, Output = Self>
+ Index<RangeTo<usize>, Output = Self>
+ Index<RangeFrom<usize>, Output = Self>
+ Index<RangeFull, Output = Self> {}
#[cfg(not(feature = "nightly"))]
impl<T: ?Sized> IndexRanges for T
where T: Index<Range<usize>, Output = Self>
+ Index<RangeTo<usize>, Output = Self>
+ Index<RangeFrom<usize>, Output = Self>
+ Index<RangeFull, Output = Self>
{}
#[cfg(feature = "nightly")]
pub trait IndexRangesMut: IndexMut<Range<usize>, Output = Self>
+ IndexMut<RangeTo<usize>, Output = Self>
+ IndexMut<RangeFrom<usize>, Output = Self>
+ IndexMut<RangeInclusive<usize>, Output = Self>
+ IndexMut<RangeToInclusive<usize>, Output = Self>
+ IndexMut<RangeFull, Output = Self>
+ IndexRanges {}
#[cfg(feature = "nightly")]
impl<T: ?Sized> IndexRangesMut for T
where T: IndexMut<Range<usize>, Output = Self>
+ IndexMut<RangeTo<usize>, Output = Self>
+ IndexMut<RangeFrom<usize>, Output = Self>
+ IndexMut<RangeInclusive<usize>, Output = Self>
+ IndexMut<RangeToInclusive<usize>, Output = Self>
+ IndexMut<RangeFull, Output = Self>
{}
#[cfg(not(feature = "nightly"))]
pub trait IndexRangesMut: IndexMut<Range<usize>, Output = Self>
+ IndexMut<RangeTo<usize>, Output = Self>
+ IndexMut<RangeFrom<usize>, Output = Self>
+ IndexMut<RangeFull, Output = Self>
+ IndexRanges {}
#[cfg(not(feature = "nightly"))]
impl<T: ?Sized> IndexRangesMut for T
where T: IndexMut<Range<usize>, Output = Self>
+ IndexMut<RangeTo<usize>, Output = Self>
+ IndexMut<RangeFrom<usize>, Output = Self>
+ IndexMut<RangeFull, Output = Self>
{}
pub trait SplitAt: Len + IndexRanges {
fn split_at(&self, index: usize) -> (&Self, &Self);
fn split_at_mut(&mut self, index: usize) -> (&mut Self, &mut Self);
}
pub trait SplitOff: LenMut {
fn split_off(&mut self, index: usize) -> Self;
}