1
Fork 0

[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old from_utf8_owned() behavior

This commit is contained in:
Simon Sapin 2013-12-23 17:45:01 +01:00
parent b8c4149293
commit 05ae134ace
33 changed files with 65 additions and 91 deletions

View file

@ -607,7 +607,7 @@ pub trait Reader {
/// This function will raise all the same conditions as the `read` method,
/// along with raising a condition if the input is not valid UTF-8.
fn read_to_str(&mut self) -> ~str {
match str::from_utf8_owned_opt(self.read_to_end()) {
match str::from_utf8_owned(self.read_to_end()) {
Some(s) => s,
None => {
io_error::cond.raise(standard_error(InvalidInput));
@ -1117,7 +1117,7 @@ pub trait Buffer: Reader {
/// The task will also fail if sequence of bytes leading up to
/// the newline character are not valid UTF-8.
fn read_line(&mut self) -> Option<~str> {
self.read_until('\n' as u8).map(str::from_utf8_owned)
self.read_until('\n' as u8).map(|line| str::from_utf8_owned(line).unwrap())
}
/// Create an iterator that reads a line on each iteration until EOF.