pub unsafe fn decode_in_place_unchecked(s: &mut [u8]) -> usize {
    // Skip bytes that are not '%'.
    let mut i = match s.iter().position(|&x| x == b'%') {
        Some(i) => i,
        None => return s.len(),
    };
    let mut dst = i;

    while i < s.len() {
        let x = s[i];
        let octet = if x == b'%' {
            // SAFETY: The caller must ensure that the string is properly encoded.
            let (hi, lo) = unsafe { (*s.get_unchecked(i + 1), *s.get_unchecked(i + 2)) };
            i += 3;
            decode_octet_unchecked(hi, lo)
        } else {
            i += 1;
            x
        };
        // SAFETY: `dst <= i < len` holds.
        unsafe { *s.get_unchecked_mut(dst) = octet }
        dst += 1;
    }
    dst
}
/// Decodes a percent-encoded string in-place assuming validity.
///
/// Returns the length of decoded bytes to the left.
///
/// # Safety
///
/// This function does not check that the string is properly encoded.
/// Any invalid encoded octet in the string will result in undefined behavior.
Decodes a percent-encoded string in-place assuming validity.
Returns the length of decoded bytes to the left.
Decodes a percent - encoded string in - place assuming validity . Returns the length of decoded bytes to the left .
pub unsafe fn decode_in_place_unchecked(s: &mut [u8]) -> usize {
    // Skip bytes that are not '%'.
    let mut i = match s.iter().position(|&x| x == b'%') {
        Some(i) => i,
        None => return s.len(),
    };
    let mut dst = i;
    while i < s.len() {
        let x = s[i];
        let octet = if x == b'%' {
            // SAFETY: The caller must ensure that the string is properly encoded.
            let (hi, lo) = unsafe { (*s.get_unchecked(i + 1), *s.get_unchecked(i + 2)) };
            i += 3;
            decode_octet_unchecked(hi, lo)
        } else {
            i += 1;
            x
        };
        // SAFETY: `dst <= i < len` holds.
        unsafe { *s.get_unchecked_mut(dst) = octet }
        dst += 1;
    }
    dst
}
pub unsafe fn decode_in_place_unchecked ( s : & mut [ u8 ] ) -> usize { // Skip bytes that are not '%'. let mut i = match s . iter ( ) . position ( | & x | x == b'%' ) { Some ( i ) => i , None => return s . len ( ) , } ; let mut dst = i ; while i < s . len ( ) { let x = s [ i ] ; let octet = if x == b'%' { // SAFETY: The caller must ensure that the string is properly encoded. let ( hi , lo ) = unsafe { ( * s . get_unchecked ( i + 1 ) , * s . get_unchecked ( i + 2 ) ) } ; i += 3 ; decode_octet_unchecked ( hi , lo ) } else { i += 1 ; x } ; // SAFETY: `dst <= i < len` holds. unsafe { * s . get_unchecked_mut ( dst ) = octet } dst += 1 ; } dst }
Decodes a percent-encoded string in-place assuming validity.
Decodes a percent - encoded string in - place assuming validity .
s
&mut [u8]
s
&mut [u8]
safety
This function does not check that the string is properly encoded.
Any invalid encoded octet in the string will result in undefined behavior.
This function does not check that the string is properly encoded . Any invalid encoded octet in the string will result in undefined behavior .