pub fn hash(&self) -> Result<HashOutput, anyhow::Error> {
        let size = self.uncompressed_size();

        let file_prefix = match self {
            Self::Commit(_) => "commit",
            Self::Tree(_) => "tree",
            Self::Blob(_) => "blob",
        };

        let size_len = itoa::Buffer::new().format(size).len();

        let mut out =
            BytesMut::with_capacity(file_prefix.len() + " ".len() + size_len + "\n".len() + size);

        write!(out, "{} {}\0", file_prefix, size)?;
        match self {
            Self::Commit(commit) => {
                commit.encode_to(&mut out)?;
            }
            Self::Tree(items) => {
                for item in items {
                    item.encode_to(&mut out)?;
                }
            }
            Self::Blob(blob) => {
                out.extend_from_slice(blob);
            }
        }

        Ok(sha1::Sha1::digest(&out))
    }
// wen const generics for RustCrypto? :-(
wen const generics for RustCrypto.
wen const generics for RustCrypto .
pub fn hash(&self) -> Result<HashOutput, anyhow::Error> {
        let size = self.uncompressed_size();
        let file_prefix = match self {
            Self::Commit(_) => "commit",
            Self::Tree(_) => "tree",
            Self::Blob(_) => "blob",
        };
        let size_len = itoa::Buffer::new().format(size).len();
        let mut out =
            BytesMut::with_capacity(file_prefix.len() + " ".len() + size_len + "\n".len() + size);
        write!(out, "{} {}\0", file_prefix, size)?;
        match self {
            Self::Commit(commit) => {
                commit.encode_to(&mut out)?;
            }
            Self::Tree(items) => {
                for item in items {
                    item.encode_to(&mut out)?;
                }
            }
            Self::Blob(blob) => {
                out.extend_from_slice(blob);
            }
        }
        Ok(sha1::Sha1::digest(&out))
    }
pub fn hash ( & self ) -> Result < HashOutput , anyhow :: Error > { let size = self . uncompressed_size ( ) ; let file_prefix = match self { Self :: Commit ( _ ) => " " , Self :: Tree ( _ ) => " " , Self :: Blob ( _ ) => " " , } ; let size_len = itoa :: Buffer :: new ( ) . format ( size ) . len ( ) ; let mut out = BytesMut :: with_capacity ( file_prefix . len ( ) + " " . len ( ) + size_len + " \n " . len ( ) + size ) ; write ! ( out " \0 " file_prefix size ) ? ; match self { Self :: Commit ( commit ) => { commit . encode_to ( & mut out ) ? ; } Self :: Tree ( items ) => { for item in items { item . encode_to ( & mut out ) ? ; } } Self :: Blob ( blob ) => { out . extend_from_slice ( blob ) ; } } Ok ( sha1 :: Sha1 :: digest ( & out ) ) }
wen const generics for RustCrypto?
wen const generics for RustCrypto?
&self
&self