mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Reuse allocations in fixing closures
This commit is contained in:
parent
d19c9107b2
commit
c0969e5ff8
3 changed files with 32 additions and 19 deletions
|
@ -140,6 +140,12 @@ impl<K: PartialEq, V> VecMap<K, V> {
|
|||
cur_idx: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Removes all key/value pairs from the map, without affecting its allocated capacity.
|
||||
pub fn clear(&mut self) {
|
||||
self.keys.clear();
|
||||
self.values.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: PartialEq, V> Extend<(K, V)> for VecMap<K, V> {
|
||||
|
|
|
@ -83,6 +83,11 @@ impl<T: PartialEq> VecSet<T> {
|
|||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T> {
|
||||
self.elements.iter_mut()
|
||||
}
|
||||
|
||||
/// Removes all elements from the set, without affecting its allocated capacity.
|
||||
pub fn clear(&mut self) {
|
||||
self.elements.clear()
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Ord> Extend<A> for VecSet<A> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue