-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix clippy lints #264
base: master
Are you sure you want to change the base?
Fix clippy lints #264
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,7 +309,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() { | ||
let ch = match self.chars().next_back() { | ||
Some(ch) => ch, | ||
None => return None, | ||
}; | ||
|
@@ -394,8 +394,8 @@ impl<const CAP: usize> ArrayString<CAP> | |
|
||
/// Set the strings’s length. | ||
/// | ||
/// This function is `unsafe` because it changes the notion of the | ||
/// number of “valid” bytes in the string. Use with care. | ||
/// # Safety | ||
/// The data must be initialised up to the length provided. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to remove the old comment. Was it incorrect? |
||
/// | ||
/// This method uses *debug assertions* to check the validity of `length` | ||
/// and may use other debug assertions. | ||
|
@@ -523,17 +523,12 @@ impl<const CAP: usize> Clone for ArrayString<CAP> | |
fn clone(&self) -> ArrayString<CAP> { | ||
*self | ||
} | ||
fn clone_from(&mut self, rhs: &Self) { | ||
// guaranteed to fit due to types matching. | ||
self.clear(); | ||
self.try_push_str(rhs).ok(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this removed? |
||
} | ||
|
||
impl<const CAP: usize> PartialOrd for ArrayString<CAP> | ||
{ | ||
fn partial_cmp(&self, rhs: &Self) -> Option<cmp::Ordering> { | ||
(**self).partial_cmp(&**rhs) | ||
Some(self.cmp(rhs)) | ||
} | ||
fn lt(&self, rhs: &Self) -> bool { **self < **rhs } | ||
fn le(&self, rhs: &Self) -> bool { **self <= **rhs } | ||
|
@@ -677,7 +672,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) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -208,11 +208,15 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> { | |
|
||
/// Push `element` to the end of the vector without checking the capacity. | ||
/// | ||
/// # Safety | ||
/// | ||
/// It is up to the caller to ensure the capacity of the vector is | ||
/// sufficiently large. | ||
/// | ||
/// This method uses *debug assertions* to check that the arrayvec is not full. | ||
/// | ||
/// # Example | ||
/// | ||
/// ``` | ||
/// use arrayvec::ArrayVec; | ||
/// | ||
|
@@ -537,8 +541,8 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> { | |
|
||
/// Set the vector’s length without dropping or moving out elements | ||
/// | ||
/// This method is `unsafe` because it changes the notion of the | ||
/// number of “valid” elements in the vector. Use with care. | ||
/// # Safety | ||
/// The data must be initialised up to the length provided. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What was wrong about the old comment? |
||
/// | ||
/// This method uses *debug assertions* to check that `length` is | ||
/// not greater than the capacity. | ||
|
@@ -664,13 +668,14 @@ impl<T, const CAP: usize> ArrayVec<T, CAP> { | |
|
||
/// Return the inner fixed size array. | ||
/// | ||
/// Safety: | ||
/// This operation is safe if and only if length equals capacity. | ||
/// # Safety | ||
/// | ||
/// [`Self::len`] must equal [`Self::capacity`]. | ||
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. | ||
|
@@ -1013,7 +1018,7 @@ impl<'a, T: 'a, const CAP: usize> Drop for Drain<'a, T, CAP> { | |
// len is currently 0 so panicking while dropping will not cause a double drop. | ||
|
||
// exhaust self first | ||
while let Some(_) = self.next() { } | ||
for _ in self.by_ref() { } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is more readable. |
||
|
||
if self.tail_len > 0 { | ||
unsafe { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to change the benchmark, it now tests a different function.