From 2a17cceb212a5df3da5bd44f105f3e70dcbe453a Mon Sep 17 00:00:00 2001 From: Nico Wagner Date: Wed, 31 Aug 2022 20:42:12 +0200 Subject: [PATCH] Fix clippy warnings (#475) --- src/bin/pica/util.rs | 2 +- src/common.rs | 4 ++-- src/field.rs | 2 +- src/matcher/common.rs | 4 ++-- src/matcher/occurrence_matcher.rs | 2 +- src/matcher/subfield_matcher.rs | 2 +- src/matcher/tag_matcher.rs | 2 +- src/occurrence.rs | 2 +- src/parser.rs | 2 +- src/path.rs | 2 +- src/record.rs | 4 ++-- src/subfield.rs | 2 +- src/tag.rs | 6 +++--- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/bin/pica/util.rs b/src/bin/pica/util.rs index 42258f356..e716fd145 100644 --- a/src/bin/pica/util.rs +++ b/src/bin/pica/util.rs @@ -21,7 +21,7 @@ impl fmt::Display for CliError { CliError::Xml(ref e) => e.fmt(f), CliError::Io(ref e) => e.fmt(f), CliError::Pica(ref e) => e.fmt(f), - CliError::Other(ref s) => f.write_str(&**s), + CliError::Other(ref s) => f.write_str(s), } } } diff --git a/src/common.rs b/src/common.rs index 9f82da024..162fb456e 100644 --- a/src/common.rs +++ b/src/common.rs @@ -42,7 +42,7 @@ fn parse_escaped_char(i: &[u8]) -> ParseResult { /// Parse a non-empty block of text that doesn't include \ or ". -fn parse_literal<'a>(i: &'a [u8]) -> ParseResult<&'a str> { +fn parse_literal(i: &[u8]) -> ParseResult<&str> { map_res( verify(is_not("\'\\"), |s: &[u8]| !s.is_empty()), std::str::from_utf8, @@ -57,7 +57,7 @@ enum StringFragment<'a> { } /// Combine parse_literal, parse_escaped_char into a StringFragment. -fn parse_fragment<'a>(i: &'a [u8]) -> ParseResult> { +fn parse_fragment(i: &[u8]) -> ParseResult { alt(( map(parse_literal, StringFragment::Literal), map(parse_escaped_char, StringFragment::EscapedChar), diff --git a/src/field.rs b/src/field.rs index b1a90e26c..a65b5c5c4 100644 --- a/src/field.rs +++ b/src/field.rs @@ -27,7 +27,7 @@ const RS: char = '\x1E'; const SP: char = '\x20'; /// A PICA+ field, that may contian invalid UTF-8 data. -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Field { pub(crate) tag: Tag, pub(crate) occurrence: Option, diff --git a/src/matcher/common.rs b/src/matcher/common.rs index 86ffeda0b..d99ca24e2 100644 --- a/src/matcher/common.rs +++ b/src/matcher/common.rs @@ -7,7 +7,7 @@ use nom::combinator::value; use crate::common::ParseResult; /// Boolean Operators. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum BooleanOp { And, // and, "&&" Or, // or, "||" @@ -23,7 +23,7 @@ impl fmt::Display for BooleanOp { } /// Comparison Operators -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum ComparisonOp { Eq, // equal, "==" Ne, // not equal, "!=" diff --git a/src/matcher/occurrence_matcher.rs b/src/matcher/occurrence_matcher.rs index 5f147d64d..e0a57e27c 100644 --- a/src/matcher/occurrence_matcher.rs +++ b/src/matcher/occurrence_matcher.rs @@ -11,7 +11,7 @@ use crate::common::ParseResult; use crate::occurrence::{parse_occurrence_digits, Occurrence}; use crate::Error; -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] pub enum OccurrenceMatcher { Some(Occurrence), Range(Occurrence, Occurrence), diff --git a/src/matcher/subfield_matcher.rs b/src/matcher/subfield_matcher.rs index dec185269..8c53e1829 100644 --- a/src/matcher/subfield_matcher.rs +++ b/src/matcher/subfield_matcher.rs @@ -30,7 +30,7 @@ macro_rules! maybe_lowercase { } /// A subfield matcher. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum SubfieldMatcher { Comparison(Vec, ComparisonOp, BString), Exists(Vec), diff --git a/src/matcher/tag_matcher.rs b/src/matcher/tag_matcher.rs index d1a84fbcd..dbf7c6c3c 100644 --- a/src/matcher/tag_matcher.rs +++ b/src/matcher/tag_matcher.rs @@ -13,7 +13,7 @@ use crate::common::ParseResult; use crate::tag::{parse_tag, Tag}; use crate::Error; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum TagMatcher { Some(Tag), Pattern(Vec, Vec, Vec, Vec), diff --git a/src/occurrence.rs b/src/occurrence.rs index 04e1d272a..351d5e366 100644 --- a/src/occurrence.rs +++ b/src/occurrence.rs @@ -16,7 +16,7 @@ use crate::common::ParseResult; use crate::error::Error; /// A PICA+ occurrence. -#[derive(Debug, Clone, PartialEq, PartialOrd)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd)] pub struct Occurrence(BString); /// Parses digits of a PICA+ occurrence. diff --git a/src/parser.rs b/src/parser.rs index b4e4801fc..5b063a00e 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -15,7 +15,7 @@ use crate::Path; const NL: char = '\x0A'; /// An error that can occur when parsing PICA+ records. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct ParsePicaError { pub message: String, pub data: Vec, diff --git a/src/path.rs b/src/path.rs index 6b6430244..61f278bd2 100644 --- a/src/path.rs +++ b/src/path.rs @@ -19,7 +19,7 @@ use crate::{Error, Result, Tag}; use std::str::FromStr; -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct Path { pub(crate) tag: TagMatcher, pub(crate) occurrence: OccurrenceMatcher, diff --git a/src/record.rs b/src/record.rs index 1abd90023..f13eff5b6 100644 --- a/src/record.rs +++ b/src/record.rs @@ -13,7 +13,7 @@ use std::ops::Deref; use std::result::Result as StdResult; /// A PICA+ record, that may contian invalid UTF-8 data. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct ByteRecord { pub(crate) raw_data: Option>, pub(crate) fields: Vec, @@ -405,7 +405,7 @@ impl Deref for ByteRecord { } /// A PICA+ record, that guarantees valid UTF-8 data. -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub struct StringRecord(ByteRecord); impl Deref for StringRecord { diff --git a/src/subfield.rs b/src/subfield.rs index 7fe82846a..3aed47a0a 100644 --- a/src/subfield.rs +++ b/src/subfield.rs @@ -16,7 +16,7 @@ use crate::common::ParseResult; use crate::error::{Error, Result}; /// A PICA+ subfield, that may contian invalid UTF-8 data. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Subfield { pub(crate) code: char, pub(crate) value: BString, diff --git a/src/tag.rs b/src/tag.rs index 0c67cd415..b689793df 100644 --- a/src/tag.rs +++ b/src/tag.rs @@ -20,7 +20,7 @@ use crate::error::Error; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Tag(pub(crate) BString); -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Eq)] pub enum Level { Main, Local, @@ -86,9 +86,9 @@ impl Tag { /// assert_eq!(Tag::new("003@")?.level(), Level::Main); /// Ok(()) /// } - /// ``` + /// ``` pub fn level(&self) -> Level { - match self.0.get(0) { + match self.0.first() { Some(b'0') => Level::Main, Some(b'1') => Level::Local, Some(b'2') => Level::Copy,