mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-23 19:48:19 +00:00
const VarInt::size
This commit is contained in:
@@ -51,7 +51,7 @@ impl VarInt {
|
||||
}
|
||||
|
||||
/// Compute the number of bytes needed to encode this value
|
||||
pub(crate) fn size(self) -> usize {
|
||||
pub(crate) const fn size(self) -> usize {
|
||||
let x = self.0;
|
||||
if x < 2u64.pow(6) {
|
||||
1
|
||||
@@ -62,7 +62,7 @@ impl VarInt {
|
||||
} else if x < 2u64.pow(62) {
|
||||
8
|
||||
} else {
|
||||
unreachable!("malformed VarInt");
|
||||
panic!("malformed VarInt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user