We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b0cf290 commit 3041d39Copy full SHA for 3041d39
src/index_map.rs
@@ -1245,7 +1245,7 @@ where
1245
///
1246
/// If `len` is greater than the map's current length, this has no effect.
1247
1248
- /// Computes in *O*(1) time (average).
+ /// Computes in *O*(n) time (average).
1249
1250
/// # Examples
1251
@@ -1267,6 +1267,15 @@ where
1267
/// ```
1268
pub fn truncate(&mut self, len: usize) {
1269
self.core.entries.truncate(len);
1270
+
1271
+ if self.core.indices.len() > self.core.entries.len() {
1272
+ for index in self.core.indices.iter_mut() {
1273
+ match index {
1274
+ Some(pos) if pos.index() >= len => *index = None,
1275
+ _ => (),
1276
+ }
1277
1278
1279
}
1280
1281
/* Private API */
0 commit comments