Skip to content

Commit

Permalink
thanks clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 12, 2022
1 parent c68b125 commit 4bd747c
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cargo-smart-release/src/command/release/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ fn find_dependency_tables<'r>(
}

fn req_as_version(req: &VersionReq) -> Option<Version> {
req.comparators.get(0).map(|comp| Version {
req.comparators.first().map(|comp| Version {
major: comp.major,
minor: comp.minor.unwrap_or(0),
patch: comp.patch.unwrap_or(0),
Expand Down
2 changes: 1 addition & 1 deletion git-config/src/file/mutable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub(crate) mod section;
pub(crate) mod value;

fn escape_value(value: &BStr) -> BString {
let starts_with_whitespace = value.get(0).map_or(false, |b| b.is_ascii_whitespace());
let starts_with_whitespace = value.first().map_or(false, |b| b.is_ascii_whitespace());
let ends_with_whitespace = value
.get(value.len().saturating_sub(1))
.map_or(false, |b| b.is_ascii_whitespace());
Expand Down
2 changes: 1 addition & 1 deletion git-config/src/parse/section/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::parse::{
};

/// The error returned by [`Header::new(…)`][super::Header::new()].
#[derive(Debug, PartialOrd, PartialEq, thiserror::Error)]
#[derive(Debug, PartialOrd, PartialEq, Eq, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("section names can only be ascii, '-'")]
Expand Down
2 changes: 1 addition & 1 deletion git-hash/src/owned/prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub mod from_hex {
use quick_error::quick_error;
quick_error! {
/// The error returned by [Prefix::from_hex][super::Prefix::from_hex()].
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
#[allow(missing_docs)]
pub enum Error {
TooShort { hex_len: usize } {
Expand Down
2 changes: 1 addition & 1 deletion git-odb/src/store_impls/dynamic/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ where

fn write_stream(&self, kind: Kind, size: u64, from: impl Read) -> Result<ObjectId, Self::Error> {
let mut snapshot = self.snapshot.borrow_mut();
Ok(match snapshot.loose_dbs.get(0) {
Ok(match snapshot.loose_dbs.first() {
Some(ldb) => ldb.write_stream(kind, size, from)?,
None => {
let new_snapshot = self
Expand Down
2 changes: 1 addition & 1 deletion git-pack/src/data/input/entries_to_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ where
.header
.write_to(entry.decompressed_size as u64, &mut self.output)?;
std::io::copy(
&mut &*entry
&mut entry
.compressed
.as_deref()
.expect("caller must configure generator to keep compressed bytes"),
Expand Down
2 changes: 1 addition & 1 deletion git-ref/src/store/packed/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub mod open {

let (offset, sorted) = {
let data = backing.as_ref();
if *data.get(0).unwrap_or(&b' ') == b'#' {
if *data.first().unwrap_or(&b' ') == b'#' {
let (records, header) = packed::decode::header::<()>(data).map_err(|_| Error::HeaderParsing)?;
let offset = records.as_ptr() as usize - data.as_ptr() as usize;
(offset, header.sorted)
Expand Down
12 changes: 5 additions & 7 deletions git-ref/src/store/packed/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,11 @@ impl packed::Buffer {

pub(crate) fn try_find_full_name(&self, name: &FullNameRef) -> Result<Option<packed::Reference<'_>>, Error> {
match self.binary_search_by(name.as_bstr()) {
Ok(line_start) => {
return Ok(Some(
packed::decode::reference::<()>(&self.as_ref()[line_start..])
.map_err(|_| Error::Parse)?
.1,
))
}
Ok(line_start) => Ok(Some(
packed::decode::reference::<()>(&self.as_ref()[line_start..])
.map_err(|_| Error::Parse)?
.1,
)),
Err((parse_failure, _)) => {
if parse_failure {
Err(Error::Parse)
Expand Down
2 changes: 1 addition & 1 deletion git-refspec/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) mod function {
}
}

let mode = match spec.get(0) {
let mode = match spec.first() {
Some(&b'^') => {
spec = &spec[1..];
if operation == Operation::Push {
Expand Down
2 changes: 1 addition & 1 deletion git-repository/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ pub mod init {
/// Not to be confused with 'status'.
pub mod state {
/// Tell what operation is currently in progress.
#[derive(Debug, PartialEq)]
#[derive(Debug, PartialEq, Eq)]
pub enum InProgress {
/// A mailbox is being applied.
ApplyMailbox,
Expand Down
2 changes: 1 addition & 1 deletion git-repository/src/repository/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl crate::Repository {
commit.parents.len(),
),
},
expected: match commit.parents.get(0).map(|p| Target::Peeled(*p)) {
expected: match commit.parents.first().map(|p| Target::Peeled(*p)) {
Some(previous) => {
if reference.as_bstr() == "HEAD" {
PreviousValue::MustExistAndMatch(previous)
Expand Down
14 changes: 7 additions & 7 deletions git-revision/src/spec/parse/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn parse(mut input: &BStr, delegate: &mut impl Delegate) -> Result<(), Error
use delegate::{Kind, Revision};
let mut delegate = InterceptRev::new(delegate);
let mut prev_kind = None;
if let Some(b'^') = input.get(0) {
if let Some(b'^') = input.first() {
input = next(input).1;
let kind = spec::Kind::ExcludeReachable;
delegate.kind(kind).ok_or(Error::Delegate)?;
Expand Down Expand Up @@ -199,7 +199,7 @@ fn try_set_prefix(delegate: &mut impl Delegate, hex_name: &BStr, hint: Option<de
fn long_describe_prefix(name: &BStr) -> Option<(&BStr, delegate::PrefixHint<'_>)> {
let mut iter = name.rsplit(|b| *b == b'-');
let candidate = iter.by_ref().find_map(|substr| {
if substr.get(0)? != &b'g' {
if substr.first()? != &b'g' {
return None;
};
let rest = substr.get(1..)?;
Expand Down Expand Up @@ -240,7 +240,7 @@ fn short_describe_prefix(name: &BStr) -> Option<&BStr> {

type InsideParensRestConsumed<'a> = (std::borrow::Cow<'a, BStr>, &'a BStr, usize);
fn parens(input: &[u8]) -> Result<Option<InsideParensRestConsumed<'_>>, Error> {
if input.get(0) != Some(&b'{') {
if input.first() != Some(&b'{') {
return Ok(None);
}
let mut open_braces = 0;
Expand Down Expand Up @@ -538,13 +538,13 @@ where
invalid => return Err(Error::InvalidObject { input: invalid.into() }),
};
delegate.peel_until(target).ok_or(Error::Delegate)?;
} else if past_sep.and_then(|i| i.get(0)) == Some(&b'!') {
} else if past_sep.and_then(|i| i.first()) == Some(&b'!') {
delegate
.kind(spec::Kind::ExcludeReachableFromParents)
.ok_or(Error::Delegate)?;
delegate.done();
return Ok(input[cursor + 1..].as_bstr());
} else if past_sep.and_then(|i| i.get(0)) == Some(&b'@') {
} else if past_sep.and_then(|i| i.first()) == Some(&b'@') {
delegate
.kind(spec::Kind::IncludeReachableFromParents)
.ok_or(Error::Delegate)?;
Expand All @@ -570,8 +570,8 @@ where

fn parse_regex_prefix(regex: &BStr) -> Result<(&BStr, bool), Error> {
Ok(match regex.strip_prefix(b"!") {
Some(regex) if regex.get(0) == Some(&b'!') => (regex.as_bstr(), false),
Some(regex) if regex.get(0) == Some(&b'-') => (regex[1..].as_bstr(), true),
Some(regex) if regex.first() == Some(&b'!') => (regex.as_bstr(), false),
Some(regex) if regex.first() == Some(&b'-') => (regex[1..].as_bstr(), true),
Some(_regex) => return Err(Error::UnspecifiedRegexModifier { regex: regex.into() }),
None => (regex, false),
})
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/net.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::str::FromStr;

#[derive(PartialEq, Debug)]
#[derive(Eq, PartialEq, Debug)]
pub enum Protocol {
V1,
V2,
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::OutputFormat;

pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=2;

#[derive(PartialEq, Debug)]
#[derive(Eq, PartialEq, Debug)]
pub enum ObjectExpansion {
None,
TreeTraversal,
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/explode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use git_repository::{
};
use quick_error::quick_error;

#[derive(PartialEq, Debug)]
#[derive(Eq, PartialEq, Debug)]
pub enum SafetyCheck {
SkipFileChecksumVerification,
SkipFileAndObjectChecksumVerification,
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use git_repository::{odb::pack, Progress};

use crate::OutputFormat;

#[derive(PartialEq, Debug)]
#[derive(Eq, PartialEq, Debug)]
pub enum IterationMode {
AsIs,
Verify,
Expand Down

0 comments on commit 4bd747c

Please sign in to comment.