Skip to content

Commit 120e8a6

Browse files
committed
EBML: Add saturating_sub back to VInt
1 parent b00d67e commit 120e8a6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lofty/src/ebml/vint.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@ macro_rules! impl_vint {
127127
VInt::<$t>::write_to(self.0 as u64, min_length, max_length, &mut ret)?;
128128
Ok(ret)
129129
}
130+
131+
#[inline]
132+
#[allow(dead_code)]
133+
pub(crate) fn saturating_sub(self, other: $t) -> Self {
134+
let v = self.0.saturating_sub(other);
135+
if v < Self::MIN {
136+
return Self(Self::MIN);
137+
}
138+
139+
Self(v)
140+
}
130141
}
131142

132143
impl Add for VInt<$t> {

0 commit comments

Comments
 (0)