Skip to content

Commit

Permalink
Rollup merge of rust-lang#23836 - Hoverbear:patch-1, r=steveklabnik
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Manishearth committed Mar 31, 2015
2 parents 8410788 + d4b5f65 commit 4038593
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/libcore/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,30 @@
//! For example,
//!
//! ```
//! # #![feature(os, old_io, old_path)]
//! #![feature(core)]
//! use std::error::FromError;
//! use std::old_io::{File, IoError};
//! use std::os::{MemoryMap, MapError};
//! use std::old_path::Path;
//! use std::{io, str};
//! use std::fs::File;
//!
//! enum MyError {
//! Io(IoError),
//! Map(MapError)
//! Io(io::Error),
//! Utf8(str::Utf8Error),
//! }
//!
//! impl FromError<IoError> for MyError {
//! fn from_error(err: IoError) -> MyError {
//! MyError::Io(err)
//! }
//! impl FromError<io::Error> for MyError {
//! fn from_error(err: io::Error) -> MyError { MyError::Io(err) }
//! }
//!
//! impl FromError<MapError> for MyError {
//! fn from_error(err: MapError) -> MyError {
//! MyError::Map(err)
//! }
//! impl FromError<str::Utf8Error> for MyError {
//! fn from_error(err: str::Utf8Error) -> MyError { MyError::Utf8(err) }
//! }
//!
//! #[allow(unused_variables)]
//! fn open_and_map() -> Result<(), MyError> {
//! let f = try!(File::open(&Path::new("foo.txt")));
//! let m = try!(MemoryMap::new(0, &[]));
//! let b = b"foo.txt";
//! let s = try!(str::from_utf8(b));
//! let f = try!(File::open(s));
//!
//! // do something interesting here...
//! Ok(())
//! }
Expand Down

0 comments on commit 4038593

Please sign in to comment.