The following code works, and I don't know why:
File::open(&some_path).read_to_end().unwrap();
Looking at the API docs, I see File::open() returning an IoResult that does not have read_to_end() .
File::open()
IoResult
read_to_end()
Is there any syntactic sugar? Can Result<T, Error> turn into Result<U, Error> ?
Result<T, Error>
Result<U, Error>
Documentation: http://doc.rust-lang.org/std/io/fs/struct.File.html#method.read_to_end
read_to_end refers to the Reader read_to_end , and if you look there, you will see that there is a read implementation for IoResult<R> for any R that implements Reader :
read_to_end
Reader
IoResult<R>
R
impl<R: Reader> Reader for IoResult<R>