]> git.lizzy.rs Git - rust.git/blob - src/libstd/prelude.rs
ef05f3b167a68144767cc6ba6ee6c6c517b09570
[rust.git] / src / libstd / prelude.rs
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 //! The Rust prelude
12 //!
13 //! Because `std` is required by most serious Rust software, it is
14 //! imported at the topmost level of every crate by default, as if the
15 //! first line of each crate was
16 //!
17 //! ```ignore
18 //! extern crate std;
19 //! ```
20 //!
21 //! This means that the contents of std can be accessed from any context
22 //! with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`,
23 //! etc.
24 //!
25 //! Additionally, `std` contains a `prelude` module that reexports many of the
26 //! most common traits, types and functions. The contents of the prelude are
27 //! imported into every *module* by default.  Implicitly, all modules behave as if
28 //! they contained the following prologue:
29 //!
30 //! ```ignore
31 //! use std::prelude::*;
32 //! ```
33 //!
34 //! The prelude is primarily concerned with exporting *traits* that are so
35 //! pervasive that it would be obnoxious to import for every use, particularly
36 //! those that define methods on primitive types. It does include a few
37 //! particularly useful standalone functions, like `from_str`, `range`, and
38 //! `drop`, `spawn`, and `channel`.
39
40 // Reexported core operators
41 #[doc(noinline)] pub use kinds::{Copy, Send, Sized, Share};
42 #[doc(noinline)] pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
43 #[doc(noinline)] pub use ops::{BitAnd, BitOr, BitXor};
44 #[doc(noinline)] pub use ops::{Drop, Deref, DerefMut};
45 #[doc(noinline)] pub use ops::{Shl, Shr, Index};
46 #[doc(noinline)] pub use option::{Option, Some, None};
47 #[doc(noinline)] pub use result::{Result, Ok, Err};
48
49 // Reexported functions
50 #[doc(noinline)] pub use from_str::from_str;
51 #[doc(noinline)] pub use iter::range;
52 #[doc(noinline)] pub use mem::drop;
53
54 // Reexported types and traits
55
56 #[doc(noinline)] pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr};
57 #[doc(noinline)] pub use ascii::IntoBytes;
58 #[doc(noinline)] pub use c_str::ToCStr;
59 #[doc(noinline)] pub use char::Char;
60 #[doc(noinline)] pub use clone::Clone;
61 #[doc(noinline)] pub use cmp::{Eq, Ord, TotalEq, TotalOrd};
62 #[doc(noinline)] pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
63 #[doc(noinline)] pub use container::{Container, Mutable, Map, MutableMap};
64 #[doc(noinline)] pub use container::{Set, MutableSet};
65 #[doc(noinline)] pub use iter::{FromIterator, Extendable, ExactSize};
66 #[doc(noinline)] pub use iter::{Iterator, DoubleEndedIterator};
67 #[doc(noinline)] pub use iter::{RandomAccessIterator, CloneableIterator};
68 #[doc(noinline)] pub use iter::{OrdIterator, MutableDoubleEndedIterator};
69 #[doc(noinline)] pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul};
70 #[doc(noinline)] pub use num::{Signed, Unsigned, Primitive, Int, Float};
71 #[doc(noinline)] pub use num::{FloatMath, ToPrimitive, FromPrimitive};
72 #[doc(noinline)] pub use option::Expect;
73 #[doc(noinline)] pub use owned::Box;
74 #[doc(noinline)] pub use path::{GenericPath, Path, PosixPath, WindowsPath};
75 #[doc(noinline)] pub use ptr::RawPtr;
76 #[doc(noinline)] pub use io::{Buffer, Writer, Reader, Seek};
77 #[doc(noinline)] pub use str::{Str, StrVector, StrSlice, OwnedStr};
78 #[doc(noinline)] pub use str::{IntoMaybeOwned, StrAllocating};
79 #[doc(noinline)] pub use to_str::{ToStr, IntoStr};
80 #[doc(noinline)] pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
81 #[doc(noinline)] pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
82 #[doc(noinline)] pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
83 #[doc(noinline)] pub use slice::{CloneableVector, ImmutableCloneableVector};
84 #[doc(noinline)] pub use slice::{MutableCloneableVector, MutableTotalOrdVector};
85 #[doc(noinline)] pub use slice::{ImmutableVector, MutableVector};
86 #[doc(noinline)] pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector};
87 #[doc(noinline)] pub use slice::{Vector, VectorVector, OwnedVector};
88 #[doc(noinline)] pub use slice::MutableVectorAllocating;
89 #[doc(noinline)] pub use string::String;
90 #[doc(noinline)] pub use vec::Vec;
91
92 // Reexported runtime types
93 #[doc(noinline)] pub use comm::{sync_channel, channel};
94 #[doc(noinline)] pub use comm::{SyncSender, Sender, Receiver};
95 #[doc(noinline)] pub use task::spawn;
96
97 // Reexported statics
98 #[cfg(not(test))]
99 #[doc(noinline)] pub use gc::GC;