Skip to content

Commit 4038593

Browse files
committed
Rollup merge of #23836 - Hoverbear:patch-1, r=steveklabnik
To not use `old_io` and `os`, which are deprecated. Since there is no more `MemoryMap` used byte parsing instead to generate the second potential error. You can see the code working fine [here](http://is.gd/4g0wwp) on the PlayPen.
2 parents 8410788 + d4b5f65 commit 4038593

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

src/libcore/error.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,33 +48,30 @@
4848
//! For example,
4949
//!
5050
//! ```
51-
//! # #![feature(os, old_io, old_path)]
51+
//! #![feature(core)]
5252
//! use std::error::FromError;
53-
//! use std::old_io::{File, IoError};
54-
//! use std::os::{MemoryMap, MapError};
55-
//! use std::old_path::Path;
53+
//! use std::{io, str};
54+
//! use std::fs::File;
5655
//!
5756
//! enum MyError {
58-
//! Io(IoError),
59-
//! Map(MapError)
57+
//! Io(io::Error),
58+
//! Utf8(str::Utf8Error),
6059
//! }
6160
//!
62-
//! impl FromError<IoError> for MyError {
63-
//! fn from_error(err: IoError) -> MyError {
64-
//! MyError::Io(err)
65-
//! }
61+
//! impl FromError<io::Error> for MyError {
62+
//! fn from_error(err: io::Error) -> MyError { MyError::Io(err) }
6663
//! }
6764
//!
68-
//! impl FromError<MapError> for MyError {
69-
//! fn from_error(err: MapError) -> MyError {
70-
//! MyError::Map(err)
71-
//! }
65+
//! impl FromError<str::Utf8Error> for MyError {
66+
//! fn from_error(err: str::Utf8Error) -> MyError { MyError::Utf8(err) }
7267
//! }
7368
//!
7469
//! #[allow(unused_variables)]
7570
//! fn open_and_map() -> Result<(), MyError> {
76-
//! let f = try!(File::open(&Path::new("foo.txt")));
77-
//! let m = try!(MemoryMap::new(0, &[]));
71+
//! let b = b"foo.txt";
72+
//! let s = try!(str::from_utf8(b));
73+
//! let f = try!(File::open(s));
74+
//!
7875
//! // do something interesting here...
7976
//! Ok(())
8077
//! }

0 commit comments

Comments
 (0)