Skip to content

Commit

Permalink
encodeasvar
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Nov 12, 2024
1 parent f6aa064 commit 12f9c97
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions utils/zerovec/src/cow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ impl<'a, V: VarULE + ?Sized + Ord> Ord for VarZeroCow<'a, V> {

// # Safety
//
// encode_var_ule_len: Defers to the impl for &V
// encode_var_ule_len: Produces the length of the contained bytes, which are known to be a valid V by invariant
//
// encode_var_ule_write: Defers to the impl for &V
// encode_var_ule_write: Writes the contained bytes, which are known to be a valid V by invariant
unsafe impl<'a, V: VarULE + ?Sized> EncodeAsVarULE<V> for VarZeroCow<'a, V> {
fn encode_var_ule_as_slices<R>(&self, _: impl FnOnce(&[&[u8]]) -> R) -> R {
// unnecessary if the other two are implemented
Expand All @@ -239,12 +239,12 @@ unsafe impl<'a, V: VarULE + ?Sized> EncodeAsVarULE<V> for VarZeroCow<'a, V> {

#[inline]
fn encode_var_ule_len(&self) -> usize {
<&V as EncodeAsVarULE<V>>::encode_var_ule_len(&self.deref())
self.as_bytes().len()
}

#[inline]
fn encode_var_ule_write(&self, dst: &mut [u8]) {
<&V as EncodeAsVarULE<V>>::encode_var_ule_write(&self.deref(), dst)
dst.copy_from_slice(self.as_bytes())
}
}

Expand Down

0 comments on commit 12f9c97

Please sign in to comment.