Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ features = ["borsh", "serde", "zeroize"]
[package.metadata.release]
no-dev-version = true
tag-name = "{{version}}"

[lints.clippy]
while_let_on_iterator = "allow"
7 changes: 2 additions & 5 deletions src/array_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,7 @@ impl<const CAP: usize> ArrayString<CAP>
/// assert_eq!(s.pop(), None);
/// ```
pub fn pop(&mut self) -> Option<char> {
let ch = match self.chars().rev().next() {
Some(ch) => ch,
None => return None,
};
let ch = self.chars().next_back()?;
let new_len = self.len() - ch.len_utf8();
unsafe {
self.set_len(new_len);
Expand Down Expand Up @@ -686,7 +683,7 @@ impl<'a, const CAP: usize> TryFrom<fmt::Arguments<'a>> for ArrayString<CAP>
fn try_from(f: fmt::Arguments<'a>) -> Result<Self, Self::Error> {
use fmt::Write;
let mut v = Self::new();
v.write_fmt(f).map_err(|e| CapacityError::new(e))?;
v.write_fmt(f).map_err(CapacityError::new)?;
Ok(v)
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/arrayvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,8 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
pub unsafe fn into_inner_unchecked(self) -> [T; CAP] {
debug_assert_eq!(self.len(), self.capacity());
let self_ = ManuallyDrop::new(self);
let array = ptr::read(self_.as_ptr() as *const [T; CAP]);
array

ptr::read(self_.as_ptr() as *const [T; CAP])
}

/// Returns the ArrayVec, replacing the original with a new empty ArrayVec.
Expand All @@ -721,7 +721,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
/// assert!(v.is_empty());
/// ```
pub fn take(&mut self) -> Self {
mem::replace(self, Self::new())
std::mem::take(self)
}

/// Return a slice containing all elements of the vector.
Expand Down Expand Up @@ -1134,6 +1134,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
///
/// If CHECK is false, the iterator must yield at most `CAP - len()` elements.
#[track_caller]
#[allow(clippy::explicit_counter_loop)]
unsafe fn extend_from_iter<I, const CHECK: bool>(&mut self, iter: I)
where I: Iterator<Item = T>
{
Expand All @@ -1142,7 +1143,7 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> {
let ptr = self.as_mut_ptr();

// WritebackGuard updates self.len on drop (both success and panic).
let mut guard = WritebackGuard { target: &mut self.len, len: len };
let mut guard = WritebackGuard { target: &mut self.len, len };

// Take elements from the input iterator and write them into
// the arrayvec, as long as there is capacity left.
Expand Down
6 changes: 3 additions & 3 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<T> CapacityError<T> {
/// Create a new `CapacityError` from `element`.
pub const fn new(element: T) -> CapacityError<T> {
CapacityError {
element: element,
element,
}
}

Expand All @@ -29,7 +29,7 @@ impl<T> CapacityError<T> {
}
}

const CAPERROR: &'static str = "insufficient capacity";
const CAPERROR: &str = "insufficient capacity";

#[cfg(feature="std")]
/// Requires `features="std"`.
Expand All @@ -43,7 +43,7 @@ impl<T> fmt::Display for CapacityError<T> {

impl<T> fmt::Debug for CapacityError<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}: {}", "CapacityError", CAPERROR)
write!(f, "{}: {}", stringify!(CapacityError), CAPERROR)
}
}

Loading