Skip to content

Commit 5fe02ac

Browse files
committed
Remove useless len parameter in insert_unchecked
1 parent 1d3f8a3 commit 5fe02ac

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ impl<T, const N: usize> ArrayVec<T, { N }> {
266266
}
267267

268268
unsafe {
269-
self.insert_unchecked(index, item, len);
269+
self.insert_unchecked(index, item);
270270
}
271271

272272
Ok(())
@@ -333,7 +333,7 @@ impl<T, const N: usize> ArrayVec<T, { N }> {
333333
// Since nothing's going to be removed, the vector's size
334334
// is going to be increased and nothing will be returned.
335335
unsafe {
336-
self.insert_unchecked(index, item, len);
336+
self.insert_unchecked(index, item);
337337
}
338338
result = None;
339339
}
@@ -342,20 +342,16 @@ impl<T, const N: usize> ArrayVec<T, { N }> {
342342
}
343343

344344
/// Insert an item into the vector without checking if the index is
345-
/// valid or if the vector isn't full or the vector's length.
345+
/// valid or if the vector isn't full.
346346
///
347347
/// # Safety
348348
///
349349
/// If you plan on using this function, you need to check for the
350-
/// 3 previously mentioned conditions yourself before calling this
350+
/// 2 previously mentioned conditions yourself before calling this
351351
/// method.
352352
#[inline]
353-
pub unsafe fn insert_unchecked(
354-
&mut self,
355-
index: usize,
356-
item: T,
357-
len: usize,
358-
) {
353+
pub unsafe fn insert_unchecked(&mut self, index: usize, item: T) {
354+
let len = self.len();
359355
self.insert_unchecked_keep_len(index, item, len);
360356
self.set_len(len + 1);
361357
}

0 commit comments

Comments
 (0)