Simplify if condition

This commit is contained in:
Hugo Osvaldo Barrera
2022-05-30 21:09:14 +02:00
parent df160d90ae
commit 689db2fcde
+1 -3
View File
@@ -31,14 +31,12 @@ fn read_body<T: Read + Write>(length: u32, socket: &mut ProxySocket<T>) {
let stdin = io::stdin(); let stdin = io::stdin();
let mut handle = stdin.lock(); let mut handle = stdin.lock();
if let Ok(_) = handle.read_exact(&mut buffer) { if handle.read_exact(&mut buffer).is_ok() && valid_length(length) {
if valid_length(length) {
socket.write_all(&buffer).unwrap(); socket.write_all(&buffer).unwrap();
socket.flush().unwrap(); socket.flush().unwrap();
read_response(socket); read_response(socket);
} }
} }
}
fn read_response<T: Read>(socket: &mut ProxySocket<T>) { fn read_response<T: Read>(socket: &mut ProxySocket<T>) {
let mut buf = vec![0; BUFFER_SIZE as usize]; let mut buf = vec![0; BUFFER_SIZE as usize];