Refactor {send,read}_message() #11
1 changed files with 2 additions and 1 deletions
|
@ -27,8 +27,9 @@ fn read_message() -> Result<String, io::Error> {
|
||||||
stdin.read_exact(&mut len)?;
|
stdin.read_exact(&mut len)?;
|
||||||
let len = u32::from_ne_bytes(len);
|
let len = u32::from_ne_bytes(len);
|
||||||
|
|
||||||
|
let mut reader = stdin.take(len as u64);
|
||||||
let mut msg = String::with_capacity(len as usize);
|
let mut msg = String::with_capacity(len as usize);
|
||||||
stdin.take(len as u64).read_to_string(&mut msg)?;
|
reader.read_to_string(&mut msg)?;
|
||||||
Ok(msg)
|
Ok(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue