I have the following code:
fn handle_client(mut stream: TcpStream) -> () { let mut buffer = [0; 4096]; stream.read(&mut buffer).expect("read fail"); let path_request: Cow<'_, str> = String::from_utf8(&buffer[..].to_vec()).unwrap();
and I need to decode from ASCII, so I am asking if an analogue of String::from_utf8
exists for ASCII encoding?
I need the code to be alike:
fn handle_client(mut stream: TcpStream) -> () { let mut buffer = [0; 4096]; stream.read(&mut buffer).expect("read fail"); let path_request: Cow<'_, str> = String::from_ascii(&buffer[..].to_vec()).unwrap();