Unified · Split
| @@ -1 +1 @@ | |||
| 1 | #![forbid(unsafe_code)] | 1 | #![forbid(unsafe_code, rust_2018_idioms)] |
| @@ -1,4 +1,4 @@ | |||
| 1 | #![forbid(unsafe_code)] | 1 | #![forbid(unsafe_code, rust_2018_idioms)] |
| 2 | 2 | ||
| 3 | pub mod hash; | 3 | pub mod hash; |
| 4 | pub mod interrupt; | 4 | pub mod interrupt; |
| @@ -1 +1 @@ | |||
| 1 | #![forbid(unsafe_code)] | 1 | #![forbid(unsafe_code, rust_2018_idioms)] |
| @@ -40,7 +40,7 @@ fn parse_message(i: &[u8]) -> IResult<&[u8], &BStr, Error> { · 39 unmodified lines | |||
| 40 | Ok((&[], &i.as_bstr())) | 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 | let (i, tree) = | 44 | let (i, tree) = |
| 45 | parse::header_field(i, b"tree", parse::hex_sha1).map_err(Error::context("tree <40 lowercase hex char>"))?; | 45 | parse::header_field(i, b"tree", parse::hex_sha1).map_err(Error::context("tree <40 lowercase hex char>"))?; |
| 46 | let (i, parents) = many0(|i| parse::header_field(i, b"parent", parse::hex_sha1))(i) | 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 | impl<'a> Blob<'a> { | 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 | Ok(Blob { data: input }) | 28 | Ok(Blob { data: input }) |
| 29 | } | 29 | } |
| 30 | } | 30 | } |
| @@ -47,7 +47,7 @@ impl<'a> Object<'a> { · 46 unmodified lines | |||
| 47 | 47 | ||
| 48 | /// Convenient access to contained objects | 48 | /// Convenient access to contained objects |
| 49 | impl<'a> Object<'a> { | 49 | impl<'a> Object<'a> { |
| 50 | pub fn as_blob(&self) -> Option<&borrowed::Blob> { | 50 | pub fn as_blob(&self) -> Option<&borrowed::Blob<'_>> { |
| 51 | match self { | 51 | match self { |
| 52 | Object::Blob(v) => Some(v), | 52 | Object::Blob(v) => Some(v), |
| 53 | _ => None, | 53 | _ => None, |
| @@ -59,13 +59,13 @@ impl<'a> Object<'a> { · 5 unmodified lines | |||
| 59 | _ => None, | 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 | match self { | 63 | match self { |
| 64 | Object::Tree(v) => Some(v), | 64 | Object::Tree(v) => Some(v), |
| 65 | _ => None, | 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 | match self { | 69 | match self { |
| 70 | Object::Tag(v) => Some(v), | 70 | Object::Tag(v) => Some(v), |
| 71 | _ => None, | 71 | _ => None, |
| @@ -72,7 +72,7 @@ pub(crate) fn hex_sha1(i: &[u8]) -> IResult<&[u8], &BStr, Error> { · 71 unmodified lines | |||
| 72 | take_while_m_n(40usize, 40, is_hex_digit_lc)(i).map(|(i, o)| (i, o.as_bstr())) | 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 | let (i, (name, email, time_in_seconds, tzsign, tzhour, tzminute)) = tuple(( | 76 | let (i, (name, email, time_in_seconds, tzsign, tzhour, tzminute)) = tuple(( |
| 77 | terminated(take_until(&b" <"[..]), take(2usize)), | 77 | terminated(take_until(&b" <"[..]), take(2usize)), |
| 78 | terminated(take_until(&b"> "[..]), take(2usize)), | 78 | terminated(take_until(&b"> "[..]), take(2usize)), |
| @@ -26,7 +26,7 @@ pub struct Tag<'a> { · 25 unmodified lines | |||
| 26 | pub pgp_signature: Option<&'a BStr>, | 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 | let (i, target) = | 30 | let (i, target) = |
| 31 | parse::header_field(i, b"object", parse::hex_sha1).map_err(Error::context("object <40 lowercase hex char>"))?; | 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 | const NULL: &[u8] = b"\0"; | 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 | let (i, mode) = terminated(take_while_m_n(5, 6, is_digit), tag(SPACE))(i)?; | 48 | let (i, mode) = terminated(take_while_m_n(5, 6, is_digit), tag(SPACE))(i)?; |
| 49 | let mode = TreeMode::try_from(mode).map_err(nom::Err::Error)?; | 49 | let mode = TreeMode::try_from(mode).map_err(nom::Err::Error)?; |
| 50 | let (i, filename) = terminated(take_while1(|b| b != NULL[0]), tag(NULL))(i)?; | 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 | let (i, entries) = all_consuming(many1(parse_entry))(i)?; | 64 | let (i, entries) = all_consuming(many1(parse_entry))(i)?; |
| 65 | Ok((i, Tree { entries })) | 65 | Ok((i, Tree { entries })) |
| 66 | } | 66 | } |
| @@ -1,4 +1,5 @@ | |||
| 1 | #![forbid(unsafe_code)] | 1 | #![forbid(unsafe_code)] |
| 2 | #![deny(rust_2018_idioms)] | ||
| 2 | 3 | ||
| 3 | use bstr::{BStr, BString, ByteSlice}; | 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 | impl<'a> From<borrowed::Object<'a>> for owned::Object { | 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 | match v { | 103 | match v { |
| 104 | borrowed::Object::Tree(v) => owned::Object::Tree(v.into()), | 104 | borrowed::Object::Tree(v) => owned::Object::Tree(v.into()), |
| 105 | borrowed::Object::Blob(v) => owned::Object::Blob(v.into()), | 105 | borrowed::Object::Blob(v) => owned::Object::Blob(v.into()), |
| @@ -21,7 +21,7 @@ impl Id { · 20 unmodified lines | |||
| 21 | pub fn kind(&self) -> crate::HashKind { | 21 | pub fn kind(&self) -> crate::HashKind { |
| 22 | crate::HashKind::Sha1 | 22 | crate::HashKind::Sha1 |
| 23 | } | 23 | } |
| 24 | pub fn to_borrowed(&self) -> borrowed::Id { | 24 | pub fn to_borrowed(&self) -> borrowed::Id<'_> { |
| 25 | borrowed::Id::from(&self.0) | 25 | borrowed::Id::from(&self.0) |
| 26 | } | 26 | } |
| 27 | pub fn as_slice(&self) -> &[u8] { | 27 | pub fn as_slice(&self) -> &[u8] { |