Skip to content

Commit

Permalink
Fix clippy lints for 1.78 (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed May 5, 2024
1 parent fcadc2a commit 0bc9a6e
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
1 change: 0 additions & 1 deletion clippy.toml
@@ -1,2 +1 @@
msrv = "1.64.0"
blacklisted-names = []
4 changes: 2 additions & 2 deletions fuzz/fuzz_targets/bench/lib.rs
Expand Up @@ -117,8 +117,8 @@ struct ArbitraryPrettyConfig {
/// Enumerate array items in comments
enumerate_arrays: bool,
#[arbitrary(with = arbitrary_ron_extensions)]
/// Enable extensions. Only configures 'implicit_some',
/// 'unwrap_newtypes', and 'unwrap_variant_newtypes' for now.
/// Enable extensions. Only configures `implicit_some`,
/// `unwrap_newtypes`, and `unwrap_variant_newtypes` for now.
extensions: Extensions,
/// Enable compact arrays, which do not insert new lines and indentation
/// between the elements of an array
Expand Down
2 changes: 2 additions & 0 deletions src/de/mod.rs
Expand Up @@ -63,6 +63,8 @@ impl<'de> Deserializer<'de> {
Ok(deserializer)
}

// FIXME: panic is not actually possible, remove once utf8_chunks is stabilized
#[allow(clippy::missing_panics_doc)]
pub fn from_bytes_with_options(input: &'de [u8], options: &Options) -> SpannedResult<Self> {
let err = match str::from_utf8(input) {
Ok(input) => return Self::from_str_with_options(input, options),
Expand Down
2 changes: 2 additions & 0 deletions src/options.rs
Expand Up @@ -121,6 +121,8 @@ impl Options {
/// A convenience function for building a deserializer
/// and deserializing a value of type `T` from a reader
/// and a seed.
// FIXME: panic is not actually possible, remove once utf8_chunks is stabilized
#[allow(clippy::missing_panics_doc)]
pub fn from_reader_seed<R, S, T>(&self, mut rdr: R, seed: S) -> SpannedResult<T>
where
R: io::Read,
Expand Down
12 changes: 6 additions & 6 deletions src/parse.rs
Expand Up @@ -192,7 +192,7 @@ impl<'a> Parser<'a> {
Ok(false)
}
})
.fold(Ok(true), |acc, x| acc.and_then(|val| x.map(|x| x && val)))
.try_fold(true, |acc, x| x.map(|x| x && acc))
}

pub fn expect_char(&mut self, expected: char, error: Error) -> Result<()> {
Expand Down Expand Up @@ -256,10 +256,10 @@ impl<'a> Parser<'a> {

fn parse_integer<T: Num>(&mut self, sign: i8) -> Result<T> {
let base = match () {
_ if self.consume_str("0b") => 2,
_ if self.consume_str("0o") => 8,
_ if self.consume_str("0x") => 16,
_ => 10,
() if self.consume_str("0b") => 2,
() if self.consume_str("0o") => 8,
() if self.consume_str("0x") => 16,
() => 10,
};

let num_bytes = self.next_chars_while_len(is_int_char);
Expand Down Expand Up @@ -324,7 +324,7 @@ impl<'a> Parser<'a> {

let num_bytes = self.next_chars_while_len(is_int_char);

if self.src()[num_bytes..].starts_with(&['i', 'u']) {
if self.src()[num_bytes..].starts_with(['i', 'u']) {
let int_cursor = self.cursor;
self.advance_bytes(num_bytes);

Expand Down
4 changes: 2 additions & 2 deletions src/ser/mod.rs
Expand Up @@ -92,8 +92,8 @@ pub struct PrettyConfig {
pub separate_tuple_members: bool,
/// Enumerate array items in comments
pub enumerate_arrays: bool,
/// Enable extensions. Only configures 'implicit_some',
/// 'unwrap_newtypes', and 'unwrap_variant_newtypes' for now.
/// Enable extensions. Only configures `implicit_some`,
/// `unwrap_newtypes`, and `unwrap_variant_newtypes` for now.
pub extensions: Extensions,
/// Enable compact arrays, which do not insert new lines and indentation
/// between the elements of an array
Expand Down
17 changes: 11 additions & 6 deletions src/value/map.rs
Expand Up @@ -73,27 +73,32 @@ impl Map {
}

/// Iterate all key-value pairs.
pub fn iter(&self) -> impl Iterator<Item = (&Value, &Value)> + DoubleEndedIterator {
#[must_use]
pub fn iter(&self) -> impl DoubleEndedIterator<Item = (&Value, &Value)> {
self.0.iter()
}

/// Iterate all key-value pairs mutably.
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&Value, &mut Value)> + DoubleEndedIterator {
#[must_use]
pub fn iter_mut(&mut self) -> impl DoubleEndedIterator<Item = (&Value, &mut Value)> {
self.0.iter_mut()
}

/// Iterate all keys.
pub fn keys(&self) -> impl Iterator<Item = &Value> + DoubleEndedIterator {
#[must_use]
pub fn keys(&self) -> impl DoubleEndedIterator<Item = &Value> {
self.0.keys()
}

/// Iterate all values.
pub fn values(&self) -> impl Iterator<Item = &Value> + DoubleEndedIterator {
#[must_use]
pub fn values(&self) -> impl DoubleEndedIterator<Item = &Value> {
self.0.values()
}

/// Iterate all values mutably.
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut Value> + DoubleEndedIterator {
#[must_use]
pub fn values_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut Value> {
self.0.values_mut()
}

Expand Down Expand Up @@ -158,7 +163,7 @@ impl Eq for Map {}

impl PartialOrd for Map {
fn partial_cmp(&self, other: &Map) -> Option<Ordering> {
self.iter().partial_cmp(other.iter())
Some(self.cmp(other))
}
}

Expand Down

0 comments on commit 0bc9a6e

Please sign in to comment.