pub fn unescape(s: &[u8]) -> Result<Vec<u8>, String> {
    let mut out = vec![];
    let mut s = s.iter().copied().fuse();
    while let Some(b) = s.next() {
        match b {
            b'\\' if s.next() == Some(b'x') => match (next_hex(&mut s), next_hex(&mut s)) {
                (Some(c1), Some(c0)) => out.push((c1 << 4) + c0),
                _ => return Err("invalid hexadecimal escape".into()),
            },
            b'\\' => continue,
            _ => out.push(b),
        }
    }
    Ok(out)
}
/// Unescapes a testdrive byte string.
///
/// The escape character is `\` and the only interesting escape sequence is
/// `\xNN`, where each `N` is a valid hexadecimal digit. All other characters
/// following a backslash are taken literally.
Unescapes a testdrive byte string.
Unescapes a testdrive byte string .
pub fn unescape(s: &[u8]) -> Result<Vec<u8>, String> {
    let mut out = vec![];
    let mut s = s.iter().copied().fuse();
    while let Some(b) = s.next() {
        match b {
            b'\\' if s.next() == Some(b'x') => match (next_hex(&mut s), next_hex(&mut s)) {
                (Some(c1), Some(c0)) => out.push((c1 << 4) + c0),
                _ => return Err("invalid hexadecimal escape".into()),
            },
            b'\\' => continue,
            _ => out.push(b),
        }
    }
    Ok(out)
}
pub fn unescape ( s : & [ u8 ] ) -> Result < Vec < u8 > , String > { let mut out = vec ! [ ] ; let mut s = s . iter ( ) . copied ( ) . fuse ( ) ; while let Some ( b ) = s . next ( ) { match b { b'\\' if s . next ( ) == Some ( b'x' ) => match ( next_hex ( & mut s ) , next_hex ( & mut s ) ) { ( Some ( c1 ) , Some ( c0 ) ) => out . push ( ( c1 << 4 ) + c0 ) , _ => return Err ( " " . into ( ) ) , } , b'\\' => continue , _ => out . push ( b ) , } } Ok ( out ) }
Unescapes a testdrive byte string.
Unescapes a testdrive byte string .
s
&[u8]
s
&[u8]