diff options
Diffstat (limited to 'src/librustc_data_structures/thin_vec.rs')
| -rw-r--r-- | src/librustc_data_structures/thin_vec.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/librustc_data_structures/thin_vec.rs b/src/librustc_data_structures/thin_vec.rs index 2befc0aa504..43002178eb9 100644 --- a/src/librustc_data_structures/thin_vec.rs +++ b/src/librustc_data_structures/thin_vec.rs @@ -53,6 +53,20 @@ impl<T> Extend<T> for ThinVec<T> { ThinVec(None) => *self = iter.into_iter().collect::<Vec<_>>().into(), } } + + fn extend_one(&mut self, item: T) { + match *self { + ThinVec(Some(ref mut vec)) => vec.push(item), + ThinVec(None) => *self = vec![item].into(), + } + } + + fn extend_reserve(&mut self, additional: usize) { + match *self { + ThinVec(Some(ref mut vec)) => vec.reserve(additional), + ThinVec(None) => *self = Vec::with_capacity(additional).into(), + } + } } impl<T: HashStable<CTX>, CTX> HashStable<CTX> for ThinVec<T> { |
