Skip to content

Commit

Permalink
feat: Kind::len_in_bytes() method (#279)
Browse files Browse the repository at this point in the history
It yields the amount of bytes needed to store the hash.
  • Loading branch information
Byron committed Dec 20, 2021
1 parent 4e89d8d commit 9a0d8b8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions git-hash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,10 @@ impl Kind {
Kind::Sha1 => 40,
}
}
/// Returns the amount of bytes taken up by the hash of the current kind
pub const fn len_in_bytes(&self) -> usize {
match self {
Kind::Sha1 => 20,
}
}
}

0 comments on commit 9a0d8b8

Please sign in to comment.