Skip to content

Commit

Permalink
Fix clippy warnings (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwagner84 authored Aug 31, 2022
1 parent e50c236 commit 2a17cce
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/bin/pica/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn parse_escaped_char(i: &[u8]) -> ParseResult<char> {

/// 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,
Expand All @@ -57,7 +57,7 @@ enum StringFragment<'a> {
}

/// Combine parse_literal, parse_escaped_char into a StringFragment.
fn parse_fragment<'a>(i: &'a [u8]) -> ParseResult<StringFragment<'a>> {
fn parse_fragment(i: &[u8]) -> ParseResult<StringFragment> {
alt((
map(parse_literal, StringFragment::Literal),
map(parse_escaped_char, StringFragment::EscapedChar),
Expand Down
2 changes: 1 addition & 1 deletion src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Occurrence>,
Expand Down
4 changes: 2 additions & 2 deletions src/matcher/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "||"
Expand All @@ -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, "!="
Expand Down
2 changes: 1 addition & 1 deletion src/matcher/occurrence_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/matcher/subfield_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ macro_rules! maybe_lowercase {
}

/// A subfield matcher.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum SubfieldMatcher {
Comparison(Vec<char>, ComparisonOp, BString),
Exists(Vec<char>),
Expand Down
2 changes: 1 addition & 1 deletion src/matcher/tag_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>, Vec<char>, Vec<char>, Vec<char>),
Expand Down
2 changes: 1 addition & 1 deletion src/occurrence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>,
Expand Down
2 changes: 1 addition & 1 deletion src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<u8>>,
pub(crate) fields: Vec<Field>,
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/subfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2a17cce

Please sign in to comment.