This is just curiosity about the design of the next() methods in the core IO module.
For example, I would expect file.lines().next()
to return a Result<Option<String>>
, it just feels more natural to me.
If the next line cannot be read for some reason I would expect to get an Err(...)
, while I would not expect to get a Some(Err(...))
. In the other case, if I can actually read from the file without errors, then I would know if there's a next line in the file or not, and I could return an Ok(Some(result))
or Ok(None)
.
What is the reason why it has been implemented the other way around? Any thoughts?