History

refactor

Sebastian Thiel committed 6 years ago

Commit e4bcfe61 parent 6a84f1312 files · +15 −14Browse files

Showing the changes to git-object/src (9 of 12 files). Show all

Unified · Split

9 files
  1. git-object/src/borrowed/commit.rs +1 −1
  2. git-object/src/borrowed/mod.rs +1 −1
  3. git-object/src/borrowed/object.rs +3 −3
  4. git-object/src/borrowed/parse.rs +1 −1
  5. git-object/src/borrowed/tag.rs +1 −1
  6. git-object/src/borrowed/tree.rs +2 −2
  7. git-object/src/lib.rs +1 −0
  8. git-object/src/owned/convert.rs +1 −1
  9. git-object/src/owned/id.rs +1 −1
git-object/src/borrowed/commit.rs+1−1
@@ -40,7 +40,7 @@ fn parse_message(i: &[u8]) -> IResult<&[u8], &BStr, Error> { · 39 unmodified lines
4040 Ok((&[], &i.as_bstr()))
4141 }
4242
43−fn parse(i: &[u8]) -> IResult<&[u8], Commit, Error> {
43+fn parse(i: &[u8]) -> IResult<&[u8], Commit<'_>, Error> {
4444 let (i, tree) =
4545 parse::header_field(i, b"tree", parse::hex_sha1).map_err(Error::context("tree <40 lowercase hex char>"))?;
4646 let (i, parents) = many0(|i| parse::header_field(i, b"parent", parse::hex_sha1))(i)
git-object/src/borrowed/mod.rs+1−1
@@ -24,7 +24,7 @@ mod blob { · 23 unmodified lines
2424 }
2525
2626 impl<'a> Blob<'a> {
27− pub fn from_bytes(input: &[u8]) -> Result<Blob, Infallible> {
27+ pub fn from_bytes(input: &[u8]) -> Result<Blob<'_>, Infallible> {
2828 Ok(Blob { data: input })
2929 }
3030 }
git-object/src/borrowed/object.rs+3−3
@@ -47,7 +47,7 @@ impl<'a> Object<'a> { · 46 unmodified lines
4747
4848 /// Convenient access to contained objects
4949 impl<'a> Object<'a> {
50− pub fn as_blob(&self) -> Option<&borrowed::Blob> {
50+ pub fn as_blob(&self) -> Option<&borrowed::Blob<'_>> {
5151 match self {
5252 Object::Blob(v) => Some(v),
5353 _ => None,
@@ -59,13 +59,13 @@ impl<'a> Object<'a> { · 5 unmodified lines
5959 _ => None,
6060 }
6161 }
62− pub fn as_tree(&self) -> Option<&borrowed::Tree> {
62+ pub fn as_tree(&self) -> Option<&borrowed::Tree<'_>> {
6363 match self {
6464 Object::Tree(v) => Some(v),
6565 _ => None,
6666 }
6767 }
68− pub fn as_tag(&self) -> Option<&borrowed::Tag> {
68+ pub fn as_tag(&self) -> Option<&borrowed::Tag<'_>> {
6969 match self {
7070 Object::Tag(v) => Some(v),
7171 _ => None,
git-object/src/borrowed/parse.rs+1−1
@@ -72,7 +72,7 @@ pub(crate) fn hex_sha1(i: &[u8]) -> IResult<&[u8], &BStr, Error> { · 71 unmodified lines
7272 take_while_m_n(40usize, 40, is_hex_digit_lc)(i).map(|(i, o)| (i, o.as_bstr()))
7373 }
7474
75−pub(crate) fn signature(i: &[u8]) -> IResult<&[u8], Signature, Error> {
75+pub(crate) fn signature(i: &[u8]) -> IResult<&[u8], Signature<'_>, Error> {
7676 let (i, (name, email, time_in_seconds, tzsign, tzhour, tzminute)) = tuple((
7777 terminated(take_until(&b" <"[..]), take(2usize)),
7878 terminated(take_until(&b"> "[..]), take(2usize)),
git-object/src/borrowed/tag.rs+1−1
@@ -26,7 +26,7 @@ pub struct Tag<'a> { · 25 unmodified lines
2626 pub pgp_signature: Option<&'a BStr>,
2727 }
2828
29−fn parse(i: &[u8]) -> IResult<&[u8], Tag, Error> {
29+fn parse(i: &[u8]) -> IResult<&[u8], Tag<'_>, Error> {
3030 let (i, target) =
3131 parse::header_field(i, b"object", parse::hex_sha1).map_err(Error::context("object <40 lowercase hex char>"))?;
3232
git-object/src/borrowed/tree.rs+2−2
@@ -44,7 +44,7 @@ impl TryFrom<&[u8]> for TreeMode { · 43 unmodified lines
4444 }
4545
4646 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> {
4848 let (i, mode) = terminated(take_while_m_n(5, 6, is_digit), tag(SPACE))(i)?;
4949 let mode = TreeMode::try_from(mode).map_err(nom::Err::Error)?;
5050 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
6060 ))
6161 }
6262
63−fn parse(i: &[u8]) -> IResult<&[u8], Tree, Error> {
63+fn parse(i: &[u8]) -> IResult<&[u8], Tree<'_>, Error> {
6464 let (i, entries) = all_consuming(many1(parse_entry))(i)?;
6565 Ok((i, Tree { entries }))
6666 }
git-object/src/lib.rs+1−0
@@ -1,4 +1,5 @@
11 #![forbid(unsafe_code)]
2+#![deny(rust_2018_idioms)]
23
34 use bstr::{BStr, BString, ByteSlice};
45
git-object/src/owned/convert.rs+1−1
@@ -99,7 +99,7 @@ impl Into<owned::tree::Entry> for borrowed::tree::Entry<'_> { · 98 unmodified lines
9999 }
100100
101101 impl<'a> From<borrowed::Object<'a>> for owned::Object {
102− fn from(v: borrowed::Object) -> Self {
102+ fn from(v: borrowed::Object<'_>) -> Self {
103103 match v {
104104 borrowed::Object::Tree(v) => owned::Object::Tree(v.into()),
105105 borrowed::Object::Blob(v) => owned::Object::Blob(v.into()),
git-object/src/owned/id.rs+1−1
@@ -21,7 +21,7 @@ impl Id { · 20 unmodified lines
2121 pub fn kind(&self) -> crate::HashKind {
2222 crate::HashKind::Sha1
2323 }
24− pub fn to_borrowed(&self) -> borrowed::Id {
24+ pub fn to_borrowed(&self) -> borrowed::Id<'_> {
2525 borrowed::Id::from(&self.0)
2626 }
2727 pub fn as_slice(&self) -> &[u8] {