Showing the changes to git-object/src (9 of 12 files). Show all
Unified · Split
| @@ -40,7 +40,7 @@ fn parse_message(i: &[u8]) -> IResult<&[u8], &BStr, Error> { · 39 unmodified lines | ||
| 40 | 40 | Ok((&[], &i.as_bstr())) |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | −fn parse(i: &[u8]) -> IResult<&[u8], Commit, Error> { | |
| 43 | +fn parse(i: &[u8]) -> IResult<&[u8], Commit<'_>, Error> { | |
| 44 | 44 | let (i, tree) = |
| 45 | 45 | parse::header_field(i, b"tree", parse::hex_sha1).map_err(Error::context("tree <40 lowercase hex char>"))?; |
| 46 | 46 | let (i, parents) = many0(|i| parse::header_field(i, b"parent", parse::hex_sha1))(i) |
| @@ -24,7 +24,7 @@ mod blob { · 23 unmodified lines | ||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | impl<'a> Blob<'a> { |
| 27 | − pub fn from_bytes(input: &[u8]) -> Result<Blob, Infallible> { | |
| 27 | + pub fn from_bytes(input: &[u8]) -> Result<Blob<'_>, Infallible> { | |
| 28 | 28 | Ok(Blob { data: input }) |
| 29 | 29 | } |
| 30 | 30 | } |
| @@ -47,7 +47,7 @@ impl<'a> Object<'a> { · 46 unmodified lines | ||
| 47 | 47 | |
| 48 | 48 | /// Convenient access to contained objects |
| 49 | 49 | impl<'a> Object<'a> { |
| 50 | − pub fn as_blob(&self) -> Option<&borrowed::Blob> { | |
| 50 | + pub fn as_blob(&self) -> Option<&borrowed::Blob<'_>> { | |
| 51 | 51 | match self { |
| 52 | 52 | Object::Blob(v) => Some(v), |
| 53 | 53 | _ => None, |
| @@ -59,13 +59,13 @@ impl<'a> Object<'a> { · 5 unmodified lines | ||
| 59 | 59 | _ => None, |
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | − pub fn as_tree(&self) -> Option<&borrowed::Tree> { | |
| 62 | + pub fn as_tree(&self) -> Option<&borrowed::Tree<'_>> { | |
| 63 | 63 | match self { |
| 64 | 64 | Object::Tree(v) => Some(v), |
| 65 | 65 | _ => None, |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | − pub fn as_tag(&self) -> Option<&borrowed::Tag> { | |
| 68 | + pub fn as_tag(&self) -> Option<&borrowed::Tag<'_>> { | |
| 69 | 69 | match self { |
| 70 | 70 | Object::Tag(v) => Some(v), |
| 71 | 71 | _ => None, |
| @@ -72,7 +72,7 @@ pub(crate) fn hex_sha1(i: &[u8]) -> IResult<&[u8], &BStr, Error> { · 71 unmodified lines | ||
| 72 | 72 | take_while_m_n(40usize, 40, is_hex_digit_lc)(i).map(|(i, o)| (i, o.as_bstr())) |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | −pub(crate) fn signature(i: &[u8]) -> IResult<&[u8], Signature, Error> { | |
| 75 | +pub(crate) fn signature(i: &[u8]) -> IResult<&[u8], Signature<'_>, Error> { | |
| 76 | 76 | let (i, (name, email, time_in_seconds, tzsign, tzhour, tzminute)) = tuple(( |
| 77 | 77 | terminated(take_until(&b" <"[..]), take(2usize)), |
| 78 | 78 | terminated(take_until(&b"> "[..]), take(2usize)), |
| @@ -26,7 +26,7 @@ pub struct Tag<'a> { · 25 unmodified lines | ||
| 26 | 26 | pub pgp_signature: Option<&'a BStr>, |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | −fn parse(i: &[u8]) -> IResult<&[u8], Tag, Error> { | |
| 29 | +fn parse(i: &[u8]) -> IResult<&[u8], Tag<'_>, Error> { | |
| 30 | 30 | let (i, target) = |
| 31 | 31 | parse::header_field(i, b"object", parse::hex_sha1).map_err(Error::context("object <40 lowercase hex char>"))?; |
| 32 | 32 | |
| @@ -44,7 +44,7 @@ impl TryFrom<&[u8]> for TreeMode { · 43 unmodified lines | ||
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | const NULL: &[u8] = b"\0"; |
| 47 | −fn parse_entry(i: &[u8]) -> IResult<&[u8], Entry, Error> { | |
| 47 | +fn parse_entry(i: &[u8]) -> IResult<&[u8], Entry<'_>, Error> { | |
| 48 | 48 | let (i, mode) = terminated(take_while_m_n(5, 6, is_digit), tag(SPACE))(i)?; |
| 49 | 49 | let mode = TreeMode::try_from(mode).map_err(nom::Err::Error)?; |
| 50 | 50 | let (i, filename) = terminated(take_while1(|b| b != NULL[0]), tag(NULL))(i)?; |
| @@ -60,7 +60,7 @@ fn parse_entry(i: &[u8]) -> IResult<&[u8], Entry, Error> { · 9 unmodified lines | ||
| 60 | 60 | )) |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | −fn parse(i: &[u8]) -> IResult<&[u8], Tree, Error> { | |
| 63 | +fn parse(i: &[u8]) -> IResult<&[u8], Tree<'_>, Error> { | |
| 64 | 64 | let (i, entries) = all_consuming(many1(parse_entry))(i)?; |
| 65 | 65 | Ok((i, Tree { entries })) |
| 66 | 66 | } |
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | #![forbid(unsafe_code)] |
| 2 | +#![deny(rust_2018_idioms)] | |
| 2 | 3 | |
| 3 | 4 | use bstr::{BStr, BString, ByteSlice}; |
| 4 | 5 | |
| @@ -99,7 +99,7 @@ impl Into<owned::tree::Entry> for borrowed::tree::Entry<'_> { · 98 unmodified lines | ||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | impl<'a> From<borrowed::Object<'a>> for owned::Object { |
| 102 | − fn from(v: borrowed::Object) -> Self { | |
| 102 | + fn from(v: borrowed::Object<'_>) -> Self { | |
| 103 | 103 | match v { |
| 104 | 104 | borrowed::Object::Tree(v) => owned::Object::Tree(v.into()), |
| 105 | 105 | borrowed::Object::Blob(v) => owned::Object::Blob(v.into()), |
| @@ -21,7 +21,7 @@ impl Id { · 20 unmodified lines | ||
| 21 | 21 | pub fn kind(&self) -> crate::HashKind { |
| 22 | 22 | crate::HashKind::Sha1 |
| 23 | 23 | } |
| 24 | − pub fn to_borrowed(&self) -> borrowed::Id { | |
| 24 | + pub fn to_borrowed(&self) -> borrowed::Id<'_> { | |
| 25 | 25 | borrowed::Id::from(&self.0) |
| 26 | 26 | } |
| 27 | 27 | pub fn as_slice(&self) -> &[u8] { |