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
fn main() {
extern crate std;
}
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:
fn main() {
use std::prelude::*;
}
use std::prelude::*;
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. It does include a few
particularly useful standalone functions, like from_str
, range
, and
drop
, spawn
, and channel
.
pub use kinds::{Copy, Send, Sized, Share}; |
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not}; |
pub use ops::{BitAnd, BitOr, BitXor}; |
pub use ops::{Drop, Deref, DerefMut}; |
pub use ops::{Shl, Shr, Index}; |
pub use option::{Option, Some, None}; |
pub use result::{Result, Ok, Err}; |
pub use from_str::from_str; |
pub use iter::range; |
pub use mem::drop; |
pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr}; |
pub use ascii::IntoBytes; |
pub use c_str::ToCStr; |
pub use char::Char; |
pub use clone::Clone; |
pub use cmp::{PartialEq, PartialOrd, Eq, Ord}; |
pub use cmp::{Ordering, Less, Equal, Greater, Equiv}; |
pub use collections::{Collection, Mutable, Map, MutableMap}; |
pub use collections::{Set, MutableSet}; |
pub use iter::{FromIterator, Extendable, ExactSize}; |
pub use iter::{Iterator, DoubleEndedIterator}; |
pub use iter::{RandomAccessIterator, CloneableIterator}; |
pub use iter::{OrdIterator, MutableDoubleEndedIterator}; |
pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv}; |
pub use num::{Signed, Unsigned, Primitive, Int, Float}; |
pub use num::{FloatMath, ToPrimitive, FromPrimitive}; |
pub use owned::Box; |
pub use path::{GenericPath, Path, PosixPath, WindowsPath}; |
pub use ptr::RawPtr; |
pub use io::{Buffer, Writer, Reader, Seek}; |
pub use str::{Str, StrVector, StrSlice, OwnedStr}; |
pub use str::{IntoMaybeOwned, StrAllocating}; |
pub use to_str::{ToStr, IntoStr}; |
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4}; |
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8}; |
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12}; |
pub use slice::{CloneableVector, ImmutableCloneableVector}; |
pub use slice::{MutableCloneableVector, MutableOrdVector}; |
pub use slice::{ImmutableVector, MutableVector}; |
pub use slice::{ImmutableEqVector, ImmutableOrdVector}; |
pub use slice::{Vector, VectorVector}; |
pub use slice::MutableVectorAllocating; |
pub use string::String; |
pub use vec::Vec; |
pub use comm::{sync_channel, channel}; |
pub use comm::{SyncSender, Sender, Receiver}; |
pub use task::spawn; |
Keyboard shortcuts
- ?
- Show this help dialog
- S
- Focus the search field
- ⇤
- Move up in search results
- ⇥
- Move down in search results
- ⏎
- Go to active search result
Search tricks
Prefix searches with a type followed by a colon (e.g.
fn:
) to restrict the search to a given type.
Accepted types are: fn
, mod
,
struct
(or str
), enum
,
trait
, typedef
(or
tdef
).