-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
I'm working on #1916 right now.
I've encountered some oddities with the utilities, for example:
pub fn read_size(child: &mut Child, size: usize) -> String {
let mut output = Vec::new();
output.resize(size, 0);
sleep(Duration::from_secs(1));
child
.stdout
.as_mut()
.unwrap()
.read(output.as_mut_slice())
.unwrap();
String::from_utf8(output).unwrap()
}The API of this function implies that size bytes are read from the Child, however .read doesn't make such a guarantee.
This should be documented, or another function such as read_exact should be used to guarantee this property.
In other places errors are simply ignored
pub fn read(&self, name: &str) -> String {
let mut f = self.open(name);
let mut contents = String::new();
let _ = f.read_to_string(&mut contents);
contents
}This code should crash on error ^, but it just goes on.
Metadata
Metadata
Assignees
Labels
No labels