Remove Pack mutable unpack methods (#443)

* Remove Pack::unpack_mut

* Remove Pack::unpack_unchecked_mut
This commit is contained in:
Tyera Eulberg 2020-09-14 15:08:14 -06:00 committed by GitHub
parent cf50a55586
commit e7a876f280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 263 additions and 459 deletions

View File

@ -47,33 +47,6 @@ pub trait Pack: Sealed {
Ok(Self::unpack_from_slice(input)?)
}
/// Borrow `Self` from `input` for the duration of the call to `f`, but first check that `Self`
/// is initialized
#[inline(never)]
fn unpack_mut<F, U>(input: &mut [u8], f: &mut F) -> Result<U, ProgramError>
where
F: FnMut(&mut Self) -> Result<U, ProgramError>,
Self: IsInitialized,
{
let mut t = Self::unpack(input)?;
let u = f(&mut t)?;
Self::pack(t, input)?;
Ok(u)
}
/// Borrow `Self` from `input` for the duration of the call to `f`, without checking that
/// `Self` has been initialized
#[inline(never)]
fn unpack_unchecked_mut<F, U>(input: &mut [u8], f: &mut F) -> Result<U, ProgramError>
where
F: FnMut(&mut Self) -> Result<U, ProgramError>,
{
let mut t = Self::unpack_unchecked(input)?;
let u = f(&mut t)?;
Self::pack(t, input)?;
Ok(u)
}
/// Pack into slice
fn pack(src: Self, dst: &mut [u8]) -> Result<(), ProgramError> {
if dst.len() != Self::LEN {

File diff suppressed because it is too large Load Diff