diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-12-22 09:04:23 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-02 08:54:06 -0800 |
| commit | 56290a004493a5d2e211f056601533253497df60 (patch) | |
| tree | ab0e7c227f9ba155ea5bfd0390cada43062924c1 /src/libstd/prelude | |
| parent | 71b46b18a274edc7f7fb60b490e5ebbb9c911462 (diff) | |
| download | rust-56290a004493a5d2e211f056601533253497df60.tar.gz rust-56290a004493a5d2e211f056601533253497df60.zip | |
std: Stabilize the prelude module
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
Diffstat (limited to 'src/libstd/prelude')
| -rw-r--r-- | src/libstd/prelude/mod.rs | 42 | ||||
| -rw-r--r-- | src/libstd/prelude/v1.rs | 51 |
2 files changed, 93 insertions, 0 deletions
diff --git a/src/libstd/prelude/mod.rs b/src/libstd/prelude/mod.rs new file mode 100644 index 00000000000..da945b4c9fa --- /dev/null +++ b/src/libstd/prelude/mod.rs @@ -0,0 +1,42 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The Rust prelude +//! +//! Because `std` is required by most serious Rust software, it is +//! imported at the topmost level of every crate by default, as if the +//! first line of each crate was +//! +//! ```ignore +//! extern crate std; +//! ``` +//! +//! This means that the contents of std can be accessed from any context +//! with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`, +//! etc. +//! +//! Additionally, `std` contains a `prelude` module that reexports many of the +//! most common traits, types and functions. The contents of the prelude are +//! imported into every *module* by default. Implicitly, all modules behave as if +//! they contained the following prologue: +//! +//! ```ignore +//! use std::prelude::v1::*; +//! ``` +//! +//! The prelude is primarily concerned with exporting *traits* that are so +//! pervasive that it would be obnoxious to import for every use, particularly +//! those that define methods on primitive types. + +#[cfg(stage0)] +pub use self::v1::*; + +#[stable] +pub mod v1; diff --git a/src/libstd/prelude/v1.rs b/src/libstd/prelude/v1.rs new file mode 100644 index 00000000000..33146f5e622 --- /dev/null +++ b/src/libstd/prelude/v1.rs @@ -0,0 +1,51 @@ +// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The first version of the prelude of the standard library. + +#![stable] + +// Reexported core operators +#[stable] #[doc(no_inline)] pub use kinds::{Copy, Send, Sized, Sync}; +#[stable] #[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce}; + +// Reexported functions +#[stable] #[doc(no_inline)] pub use mem::drop; + +// Reexported types and traits + +#[stable] #[doc(no_inline)] pub use boxed::Box; +#[stable] #[doc(no_inline)] pub use char::{Char, UnicodeChar}; +#[stable] #[doc(no_inline)] pub use clone::Clone; +#[stable] #[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord}; +#[stable] #[doc(no_inline)] pub use iter::CloneIteratorExt; +#[stable] #[doc(no_inline)] pub use iter::DoubleEndedIterator; +#[stable] #[doc(no_inline)] pub use iter::DoubleEndedIteratorExt; +#[stable] #[doc(no_inline)] pub use iter::ExactSizeIterator; +#[stable] #[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend}; +#[stable] #[doc(no_inline)] pub use iter::{IteratorCloneExt, IteratorOrdExt}; +#[stable] #[doc(no_inline)] pub use iter::IteratorPairExt; +#[stable] #[doc(no_inline)] pub use option::Option::{mod, Some, None}; +#[stable] #[doc(no_inline)] pub use ptr::{PtrExt, MutPtrExt}; +#[stable] #[doc(no_inline)] pub use result::Result::{mod, Ok, Err}; +#[stable] #[doc(no_inline)] pub use slice::AsSlice; +#[stable] #[doc(no_inline)] pub use slice::{BoxedSliceExt, SliceExt}; +#[stable] #[doc(no_inline)] pub use slice::{CloneSliceExt, OrdSliceExt}; +#[stable] #[doc(no_inline)] pub use slice::{PartialEqSliceExt, SliceConcatExt}; +#[stable] #[doc(no_inline)] pub use str::{Str, StrExt}; +#[stable] #[doc(no_inline)] pub use string::{String, ToString}; +#[stable] #[doc(no_inline)] pub use vec::Vec; + +// NB: remove when path reform lands +#[doc(no_inline)] pub use path::{Path, GenericPath}; +// NB: remove when I/O reform lands +#[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek, BufferPrelude}; +// NB: remove when range syntax lands +#[doc(no_inline)] pub use iter::range; |
