Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Oct 27, 2023
1 parent 9afdfc2 commit 6dd83eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/arch/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) const fn check(mut input: &[u8]) -> bool {
true
}

/// Default unchecked decoding function.
/// Default checked decoding function.
///
/// # Safety
///
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ pub fn decode<T: AsRef<[u8]>>(input: T) -> Result<Vec<u8>, FromHexError> {
}

// SAFETY: Lengths are checked above.
unsafe { decode_real(input, &mut output) }.map(|()| output)
unsafe { decode_checked(input, &mut output) }.map(|()| output)
}

decode_inner(input.as_ref())
Expand Down Expand Up @@ -609,11 +609,14 @@ fn decode_to_slice_inner(input: &[u8], output: &mut [u8]) -> Result<(), FromHexE
return Err(FromHexError::InvalidStringLength);
}
// SAFETY: Lengths are checked above.
unsafe { decode_real(input, output) }
unsafe { decode_checked(input, output) }
}

/// # Safety
///
/// Assumes `output.len() == input.len() / 2`.
#[inline]
unsafe fn decode_real(input: &[u8], output: &mut [u8]) -> Result<(), FromHexError> {
unsafe fn decode_checked(input: &[u8], output: &mut [u8]) -> Result<(), FromHexError> {
if imp::USE_CHECK_FN {
// check then decode
if imp::check(input) {
Expand Down

0 comments on commit 6dd83eb

Please sign in to comment.