Browse Source

refactor

pull/21/head
Sebastian Thiel 9 months ago
parent
commit
e4bcfe6406
No known key found for this signature in database GPG Key ID: 85194C08421980C9
  1. 2
      git-commitgraph/src/lib.rs
  2. 2
      git-features/src/lib.rs
  3. 2
      git-index/src/lib.rs
  4. 2
      git-object/src/borrowed/commit.rs
  5. 2
      git-object/src/borrowed/mod.rs
  6. 6
      git-object/src/borrowed/object.rs
  7. 2
      git-object/src/borrowed/parse.rs
  8. 2
      git-object/src/borrowed/tag.rs
  9. 4
      git-object/src/borrowed/tree.rs
  10. 1
      git-object/src/lib.rs
  11. 2
      git-object/src/owned/convert.rs
  12. 2
      git-object/src/owned/id.rs

2
git-commitgraph/src/lib.rs

@ -1 +1 @@
#![forbid(unsafe_code)]
#![forbid(unsafe_code, rust_2018_idioms)]

2
git-features/src/lib.rs

@ -1,4 +1,4 @@
#![forbid(unsafe_code)]
#![forbid(unsafe_code, rust_2018_idioms)]
pub mod hash;
pub mod interrupt;

2
git-index/src/lib.rs

@ -1 +1 @@
#![forbid(unsafe_code)]
#![forbid(unsafe_code, rust_2018_idioms)]

2
git-object/src/borrowed/commit.rs

@ -40,7 +40,7 @@ fn parse_message(i: &[u8]) -> IResult<&[u8], &BStr, Error> {
Ok((&[], &i.as_bstr()))
}
fn parse(i: &[u8]) -> IResult<&[u8], Commit, Error> {
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)

2
git-object/src/borrowed/mod.rs

@ -24,7 +24,7 @@ mod blob {
}
impl<'a> Blob<'a> {
pub fn from_bytes(input: &[u8]) -> Result<Blob, Infallible> {
pub fn from_bytes(input: &[u8]) -> Result<Blob<'_>, Infallible> {
Ok(Blob { data: input })
}
}

6
git-object/src/borrowed/object.rs

@ -47,7 +47,7 @@ impl<'a> Object<'a> {
/// Convenient access to contained objects
impl<'a> Object<'a> {
pub fn as_blob(&self) -> Option<&borrowed::Blob> {
pub fn as_blob(&self) -> Option<&borrowed::Blob<'_>> {
match self {
Object::Blob(v) => Some(v),
_ => None,
@ -59,13 +59,13 @@ impl<'a> Object<'a> {
_ => None,
}
}
pub fn as_tree(&self) -> Option<&borrowed::Tree> {
pub fn as_tree(&self) -> Option<&borrowed::Tree<'_>> {
match self {
Object::Tree(v) => Some(v),
_ => None,
}
}
pub fn as_tag(&self) -> Option<&borrowed::Tag> {
pub fn as_tag(&self) -> Option<&borrowed::Tag<'_>> {
match self {
Object::Tag(v) => Some(v),
_ => None,

2
git-object/src/borrowed/parse.rs

@ -72,7 +72,7 @@ pub(crate) fn hex_sha1(i: &[u8]) -> IResult<&[u8], &BStr, Error> {
take_while_m_n(40usize, 40, is_hex_digit_lc)(i).map(|(i, o)| (i, o.as_bstr()))
}
pub(crate) fn signature(i: &[u8]) -> IResult<&[u8], Signature, Error> {
pub(crate) fn signature(i: &[u8]) -> IResult<&[u8], Signature<'_>, Error> {
let (i, (name, email, time_in_seconds, tzsign, tzhour, tzminute)) = tuple((
terminated(take_until(&b" <"[..]), take(2usize)),
terminated(take_until(&b"> "[..]), take(2usize)),

2
git-object/src/borrowed/tag.rs

@ -26,7 +26,7 @@ pub struct Tag<'a> {
pub pgp_signature: Option<&'a BStr>,
}
fn parse(i: &[u8]) -> IResult<&[u8], Tag, Error> {
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>"))?;

4
git-object/src/borrowed/tree.rs

@ -44,7 +44,7 @@ impl TryFrom<&[u8]> for TreeMode {
}
const NULL: &[u8] = b"\0";
fn parse_entry(i: &[u8]) -> IResult<&[u8], Entry, Error> {
fn parse_entry(i: &[u8]) -> IResult<&[u8], Entry<'_>, Error> {
let (i, mode) = terminated(take_while_m_n(5, 6, is_digit), tag(SPACE))(i)?;
let mode = TreeMode::try_from(mode).map_err(nom::Err::Error)?;
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> {
))
}
fn parse(i: &[u8]) -> IResult<&[u8], Tree, Error> {
fn parse(i: &[u8]) -> IResult<&[u8], Tree<'_>, Error> {
let (i, entries) = all_consuming(many1(parse_entry))(i)?;
Ok((i, Tree { entries }))
}

1
git-object/src/lib.rs

@ -1,4 +1,5 @@
#![forbid(unsafe_code)]
#![deny(rust_2018_idioms)]
use bstr::{BStr, BString, ByteSlice};

2
git-object/src/owned/convert.rs

@ -99,7 +99,7 @@ impl Into<owned::tree::Entry> for borrowed::tree::Entry<'_> {
}
impl<'a> From<borrowed::Object<'a>> for owned::Object {
fn from(v: borrowed::Object) -> Self {
fn from(v: borrowed::Object<'_>) -> Self {
match v {
borrowed::Object::Tree(v) => owned::Object::Tree(v.into()),
borrowed::Object::Blob(v) => owned::Object::Blob(v.into()),

2
git-object/src/owned/id.rs

@ -21,7 +21,7 @@ impl Id {
pub fn kind(&self) -> crate::HashKind {
crate::HashKind::Sha1
}
pub fn to_borrowed(&self) -> borrowed::Id {
pub fn to_borrowed(&self) -> borrowed::Id<'_> {
borrowed::Id::from(&self.0)
}
pub fn as_slice(&self) -> &[u8] {

Loading…
Cancel
Save