Skip to content

Commit 9a5b1fa

Browse files
authored
Merge pull request #236 from cuviper/modules
Refactor modules (no functional change)
2 parents b283dd7 + 36c918d commit 9a5b1fa

File tree

8 files changed

+1968
-1881
lines changed

8 files changed

+1968
-1881
lines changed

src/map.rs

Lines changed: 19 additions & 849 deletions
Large diffs are not rendered by default.

src/map/iter.rs

Lines changed: 463 additions & 0 deletions
Large diffs are not rendered by default.

src/map/slice.rs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -169,51 +169,37 @@ impl<K, V> Slice<K, V> {
169169

170170
/// Return an iterator over the key-value pairs of the map slice.
171171
pub fn iter(&self) -> Iter<'_, K, V> {
172-
Iter {
173-
iter: self.entries.iter(),
174-
}
172+
Iter::new(&self.entries)
175173
}
176174

177175
/// Return an iterator over the key-value pairs of the map slice.
178176
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> {
179-
IterMut {
180-
iter: self.entries.iter_mut(),
181-
}
177+
IterMut::new(&mut self.entries)
182178
}
183179

184180
/// Return an iterator over the keys of the map slice.
185181
pub fn keys(&self) -> Keys<'_, K, V> {
186-
Keys {
187-
iter: self.entries.iter(),
188-
}
182+
Keys::new(&self.entries)
189183
}
190184

191185
/// Return an owning iterator over the keys of the map slice.
192186
pub fn into_keys(self: Box<Self>) -> IntoKeys<K, V> {
193-
IntoKeys {
194-
iter: self.into_entries().into_iter(),
195-
}
187+
IntoKeys::new(self.into_entries())
196188
}
197189

198190
/// Return an iterator over the values of the map slice.
199191
pub fn values(&self) -> Values<'_, K, V> {
200-
Values {
201-
iter: self.entries.iter(),
202-
}
192+
Values::new(&self.entries)
203193
}
204194

205195
/// Return an iterator over mutable references to the the values of the map slice.
206196
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
207-
ValuesMut {
208-
iter: self.entries.iter_mut(),
209-
}
197+
ValuesMut::new(&mut self.entries)
210198
}
211199

212200
/// Return an owning iterator over the values of the map slice.
213201
pub fn into_values(self: Box<Self>) -> IntoValues<K, V> {
214-
IntoValues {
215-
iter: self.into_entries().into_iter(),
216-
}
202+
IntoValues::new(self.into_entries())
217203
}
218204
}
219205

@@ -240,9 +226,7 @@ impl<K, V> IntoIterator for Box<Slice<K, V>> {
240226
type Item = (K, V);
241227

242228
fn into_iter(self) -> Self::IntoIter {
243-
IntoIter {
244-
iter: self.into_entries().into_iter(),
245-
}
229+
IntoIter::new(self.into_entries())
246230
}
247231
}
248232

0 commit comments

Comments
 (0)