File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,22 @@ impl<V> VecMap<V> {
115115 VecMap { v : Vec :: with_capacity ( capacity) }
116116 }
117117
118+ /// Returns the number of elements the `VecMap` can hold without
119+ /// reallocating.
120+ ///
121+ /// # Example
122+ ///
123+ /// ```
124+ /// use std::collections::VecMap;
125+ /// let map: VecMap<String> = VecMap::with_capacity(10);
126+ /// assert!(map.capacity() >= 10);
127+ /// ```
128+ #[ inline]
129+ #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
130+ pub fn capacity ( & self ) -> uint {
131+ self . v . capacity ( )
132+ }
133+
118134 /// Returns an iterator visiting all keys in ascending order by the keys.
119135 /// The iterator's element type is `uint`.
120136 #[ unstable = "matches collection reform specification, waiting for dust to settle" ]
You can’t perform that action at this time.
0 commit comments