Module std::prelude
[−]
[src]
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
each crate contains the following:
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::thread::spawn
,
etc.
Additionally, std
contains a versioned prelude 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 use
statement:
use std::prelude::v1::*;
The prelude is primarily concerned with exporting traits that are so pervasive that they would be onerous to import for every use, particularly those that are commonly mentioned in generic type bounds.
The current version of the prelude (version 1) lives in
std::prelude::v1
, and reexports the following.
std::marker::
{Copy
,Send
,Sized
,Sync
}. The marker traits indicate fundamental properties of types.std::ops::
{Drop
,Fn
,FnMut
,FnOnce
}. The destructor trait and the closure traits, reexported from the same module that also defines overloaded operators.std::mem::
drop
. A convenience function for explicitly dropping a value.std::boxed::
Box
. The owned heap pointer.std::borrow::
ToOwned
. The conversion trait that definesto_owned
, the generic method for creating an owned type from a borrowed type.std::clone::
Clone
. The ubiquitous trait that definesclone
, the method for producing copies of values that are consider expensive to copy.std::cmp::
{PartialEq
,PartialOrd
,Eq
,Ord
}. The comparision traits, which implement the comparison operators and are often seen in trait bounds.std::convert::
{AsRef
,AsMut
,Into
,From
}. Generic conversions, used by savvy API authors to create overloaded methods.std::default::
Default
. Types that have default values.std::iter::
{Iterator
,Extend
,IntoIterator
,DoubleEndedIterator
,ExactSizeIterator
}. Iterators.std::option::Option::
{self
,Some
,None
}. The ubiquitousOption
type and its two variants,Some
andNone
.std::result::Result::
{self
,Ok
,Err
}. The ubiquitousResult
type and its two variants,Ok
andErr
.std::slice::
SliceConcatExt
. An unstable extension to slices that shouldn't have to exist.std::string::
{String
,ToString
}. Heap allocated strings.std::vec::
Vec
. Heap allocated vectors.
Reexports
use core::prelude::v1::*; |
Modules
v1 |
The first version of the prelude of The Rust Standard Library. |