Skip to content

Commit cb12172

Browse files
authored
Default trait & clippy warnings (#13)
1 parent 4fa0db4 commit cb12172

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/default.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use crate::{LocalVec, CopyLocalVec};
2+
3+
impl<T, const N: usize> Default for LocalVec<T, N> {
4+
fn default() -> Self {
5+
Self::new()
6+
}
7+
}
8+
9+
impl<T: Copy, const N: usize> Default for CopyLocalVec<T, N> {
10+
fn default() -> Self {
11+
Self::new()
12+
}
13+
}

src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod deref;
88
mod iter;
99
mod extend;
1010
mod eq;
11+
mod default;
1112

1213
/// A fixed-capacity vector that directly stores its elements
1314
#[derive(Eq, PartialEq, Clone, Debug)]
@@ -84,6 +85,10 @@ impl<T, const N: usize> LocalVecImpl<T, N> {
8485
self.len
8586
}
8687

88+
/// Forces the length of the local vector to `new_len`
89+
/// # Safety
90+
/// - `new_len` must be less than or equal to [`capacity()`].
91+
/// - The elements at `old_len..new_len` must be initialized.
8792
pub unsafe fn set_len(&mut self, len: usize) {
8893
self.len = len;
8994
}
@@ -116,8 +121,8 @@ impl<T, const N: usize> LocalVecImpl<T, N> {
116121
}
117122

118123
pub fn clear(&mut self) {
119-
while let Some(_) = self.pop() {
120-
}
124+
// TODO order should be the opposite of this (due to drop order)
125+
while self.pop().is_some() {}
121126
debug_assert_eq!(self.len, 0);
122127
}
123128

0 commit comments

Comments
 (0)