[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old from_utf8_owned() behavior
This commit is contained in:
parent
b8c4149293
commit
05ae134ace
33 changed files with 65 additions and 91 deletions
|
|
@ -754,7 +754,7 @@ mod test {
|
|||
let mut read_buf = [0, .. 1028];
|
||||
let read_str = match read_stream.read(read_buf).unwrap() {
|
||||
-1|0 => fail!("shouldn't happen"),
|
||||
n => str::from_utf8_owned(read_buf.slice_to(n).to_owned())
|
||||
n => str::from_utf8_owned(read_buf.slice_to(n).to_owned()).unwrap()
|
||||
};
|
||||
assert_eq!(read_str, message.to_owned());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue