diff --git a/demos/git-count.rs b/demos/git-count.rs index 5ef45ab126b..3422f96b291 100644 --- a/demos/git-count.rs +++ b/demos/git-count.rs @@ -44,14 +44,7 @@ fn run() -> Result<()> { .par_iter() .fold( || (0, 0, 0, 0, 0), - |(mut deltas, mut commits, mut trees, mut blobs, mut tags): ( - u32, - u32, - u32, - u32, - u32, - ), - entry| { + |(mut deltas, mut commits, mut trees, mut blobs, mut tags): (u32, u32, u32, u32, u32), entry| { match pack.entry(entry.pack_offset).header { Commit => commits += 1, Tag => tags += 1, diff --git a/git-features/src/parallel.rs b/git-features/src/parallel.rs index 24f628b45a5..25cc69c9dcc 100644 --- a/git-features/src/parallel.rs +++ b/git-features/src/parallel.rs @@ -10,10 +10,7 @@ mod serial { use crate::parallel::Reducer; #[cfg(not(feature = "parallel"))] - pub fn join( - left: impl FnOnce() -> O1 + Send, - right: impl FnOnce() -> O2 + Send, - ) -> (O1, O2) { + pub fn join(left: impl FnOnce() -> O1 + Send, right: impl FnOnce() -> O2 + Send) -> (O1, O2) { (left(), right()) } @@ -41,10 +38,7 @@ mod in_parallel { use crate::parallel::Reducer; use crossbeam_utils::thread; - pub fn join( - left: impl FnOnce() -> O1 + Send, - right: impl FnOnce() -> O2 + Send, - ) -> (O1, O2) { + pub fn join(left: impl FnOnce() -> O1 + Send, right: impl FnOnce() -> O2 + Send) -> (O1, O2) { thread::scope(|s| { let left = s.spawn(|_| left()); let right = s.spawn(|_| right()); diff --git a/git-features/src/progress/log.rs b/git-features/src/progress/log.rs index 7879fb7acf2..7afbf22df6e 100644 --- a/git-features/src/progress/log.rs +++ b/git-features/src/progress/log.rs @@ -47,9 +47,7 @@ impl Progress for Log { { self.last_set = Some(now); match (self.max, self.unit) { - (Some(max), Some(unit)) => { - log::info!("{} → {} / {} {}", self.name, step, max, unit) - } + (Some(max), Some(unit)) => log::info!("{} → {} / {} {}", self.name, step, max, unit), (None, Some(unit)) => log::info!("{} → {} {}", self.name, step, unit), (Some(max), None) => log::info!("{} → {} / {}", self.name, step, max), (None, None) => log::info!("{} → {}", self.name, step), diff --git a/git-object/src/borrowed/commit.rs b/git-object/src/borrowed/commit.rs index 82991af8b37..b330f4ffa1a 100644 --- a/git-object/src/borrowed/commit.rs +++ b/git-object/src/borrowed/commit.rs @@ -31,30 +31,24 @@ pub struct Commit<'data> { pub fn parse_message(i: &[u8]) -> IResult<&[u8], &BStr, Error> { if i.is_empty() { // newline + [message] - return Err(nom::Err::Error(Error::NomDetail( - i.into(), - "commit message is missing", - ))); + return Err(nom::Err::Error(Error::NomDetail(i.into(), "commit message is missing"))); } - let (i, _) = tag(NL)(i).map_err(Error::context( - "a newline separates headers from the message", - ))?; + let (i, _) = tag(NL)(i).map_err(Error::context("a newline separates headers from the message"))?; debug_assert!(!i.is_empty()); Ok((&[], &i.as_bstr())) } pub fn parse(i: &[u8]) -> IResult<&[u8], Commit, Error> { - let (i, tree) = parse_header_field(i, b"tree", parse_hex_sha1) - .map_err(Error::context("tree <40 lowercase hex char>"))?; - let (i, parents) = many0(|i| parse_header_field(i, b"parent", parse_hex_sha1))(i).map_err( - Error::context("zero or more 'parent <40 lowercase hex char>'"), - )?; - let (i, author) = parse_header_field(i, b"author", parse_signature) - .map_err(Error::context("author "))?; - let (i, committer) = parse_header_field(i, b"committer", parse_signature) - .map_err(Error::context("author "))?; - let (i, encoding) = opt(|i| parse_header_field(i, b"encoding", is_not(NL)))(i) - .map_err(Error::context("author "))?; + let (i, tree) = + parse_header_field(i, b"tree", parse_hex_sha1).map_err(Error::context("tree <40 lowercase hex char>"))?; + let (i, parents) = many0(|i| parse_header_field(i, b"parent", parse_hex_sha1))(i) + .map_err(Error::context("zero or more 'parent <40 lowercase hex char>'"))?; + let (i, author) = + parse_header_field(i, b"author", parse_signature).map_err(Error::context("author "))?; + let (i, committer) = + parse_header_field(i, b"committer", parse_signature).map_err(Error::context("author "))?; + let (i, encoding) = + opt(|i| parse_header_field(i, b"encoding", is_not(NL)))(i).map_err(Error::context("author "))?; let (i, pgp_signature) = opt(alt(( |i| parse_header_field_multiline(i, b"gpgsig"), |i| parse_header_field(i, b"gpgsig", is_not(NL)), diff --git a/git-object/src/borrowed/tag.rs b/git-object/src/borrowed/tag.rs index 83115f65c22..7f77e3d6d12 100644 --- a/git-object/src/borrowed/tag.rs +++ b/git-object/src/borrowed/tag.rs @@ -28,19 +28,18 @@ pub struct Tag<'data> { } fn parse(i: &[u8]) -> IResult<&[u8], Tag, Error> { - let (i, target) = parse_header_field(i, b"object", parse_hex_sha1) - .map_err(Error::context("object <40 lowercase hex char>"))?; + let (i, target) = + parse_header_field(i, b"object", parse_hex_sha1).map_err(Error::context("object <40 lowercase hex char>"))?; - let (i, kind) = parse_header_field(i, b"type", take_while1(is_alphabetic)) - .map_err(Error::context("type "))?; - let kind = - crate::Kind::from_bytes(kind).map_err(|e| nom::Err::Error(Error::ParseKindError(e)))?; + let (i, kind) = + parse_header_field(i, b"type", take_while1(is_alphabetic)).map_err(Error::context("type "))?; + let kind = crate::Kind::from_bytes(kind).map_err(|e| nom::Err::Error(Error::ParseKindError(e)))?; - let (i, tag_version) = parse_header_field(i, b"tag", take_while1(|b| b != NL[0])) - .map_err(Error::context("tag "))?; + let (i, tag_version) = + parse_header_field(i, b"tag", take_while1(|b| b != NL[0])).map_err(Error::context("tag "))?; - let (i, signature) = parse_header_field(i, b"tagger", parse_signature) - .map_err(Error::context("tagger "))?; + let (i, signature) = + parse_header_field(i, b"tagger", parse_signature).map_err(Error::context("tagger "))?; let (i, (message, pgp_signature)) = all_consuming(parse_message)(i)?; Ok(( i, @@ -65,10 +64,7 @@ fn parse_message(i: &[u8]) -> IResult<&[u8], (&BStr, Option<&BStr>), Error> { let (i, _) = tag(NL)(i)?; fn all_to_end(i: &[u8]) -> IResult<&[u8], (&[u8], &[u8]), Error> { if i.is_empty() { - return Err(nom::Err::Error(Error::NomDetail( - i.into(), - "tag message is missing", - ))); + return Err(nom::Err::Error(Error::NomDetail(i.into(), "tag message is missing"))); } // an empty signature message signals that there is none - the function signature is needed // to work with 'alt(…)'. PGP signatures are never empty diff --git a/git-object/src/borrowed/util/mod.rs b/git-object/src/borrowed/util/mod.rs index 328f07e6616..6a44ae5bf88 100644 --- a/git-object/src/borrowed/util/mod.rs +++ b/git-object/src/borrowed/util/mod.rs @@ -15,10 +15,7 @@ use nom::{ pub(crate) const NL: &[u8] = b"\n"; pub(crate) const SPACE: &[u8] = b" "; -pub(crate) fn parse_header_field_multiline<'a>( - i: &'a [u8], - name: &'static [u8], -) -> IResult<&'a [u8], &'a [u8], Error> { +pub(crate) fn parse_header_field_multiline<'a>(i: &'a [u8], name: &'static [u8]) -> IResult<&'a [u8], &'a [u8], Error> { let (i, o) = peek(preceded( terminated(tag(name), tag(SPACE)), recognize(tuple(( @@ -38,10 +35,7 @@ pub(crate) fn parse_header_field<'a, T>( name: &'static [u8], parse_value: impl Fn(&'a [u8]) -> IResult<&'a [u8], T, Error>, ) -> IResult<&'a [u8], T, Error> { - terminated( - preceded(terminated(tag(name), tag(SPACE)), parse_value), - tag(NL), - )(i) + terminated(preceded(terminated(tag(name), tag(SPACE)), parse_value), tag(NL))(i) } fn is_hex_digit_lc(b: u8) -> bool { @@ -69,25 +63,11 @@ pub(crate) fn parse_signature(i: &[u8]) -> IResult<&[u8], Signature, Error> { "tagger <>