]> git.lizzy.rs Git - rust.git/blob - src/libstd/prelude.rs
auto merge of #15619 : kwantam/rust/master, r=huonw
[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 #![experimental]
41
42 // Reexported core operators
43 #[doc(no_inline)] pub use kinds::{Copy, Send, Sized, Share};
44 #[doc(no_inline)] pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
45 #[doc(no_inline)] pub use ops::{BitAnd, BitOr, BitXor};
46 #[doc(no_inline)] pub use ops::{Drop, Deref, DerefMut};
47 #[doc(no_inline)] pub use ops::{Shl, Shr};
48 #[doc(no_inline)] pub use ops::{Index, IndexMut};
49 #[doc(no_inline)] pub use option::{Option, Some, None};
50 #[doc(no_inline)] pub use result::{Result, Ok, Err};
51
52 // Reexported functions
53 #[doc(no_inline)] pub use from_str::from_str;
54 #[doc(no_inline)] pub use iter::range;
55 #[doc(no_inline)] pub use mem::drop;
56
57 // Reexported types and traits
58
59 #[doc(no_inline)] pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr};
60 #[doc(no_inline)] pub use ascii::IntoBytes;
61 #[doc(no_inline)] pub use c_str::ToCStr;
62 #[doc(no_inline)] pub use char::{Char, UnicodeChar};
63 #[doc(no_inline)] pub use clone::Clone;
64 #[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
65 #[doc(no_inline)] pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
66 #[doc(no_inline)] pub use collections::{Collection, Mutable, Map, MutableMap};
67 #[doc(no_inline)] pub use collections::{Set, MutableSet};
68 #[doc(no_inline)] pub use iter::{FromIterator, Extendable, ExactSize};
69 #[doc(no_inline)] pub use iter::{Iterator, DoubleEndedIterator};
70 #[doc(no_inline)] pub use iter::{RandomAccessIterator, CloneableIterator};
71 #[doc(no_inline)] pub use iter::{OrdIterator, MutableDoubleEndedIterator};
72 #[doc(no_inline)] pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul, CheckedDiv};
73 #[doc(no_inline)] pub use num::{Signed, Unsigned, Primitive, Int, Float};
74 #[doc(no_inline)] pub use num::{FloatMath, ToPrimitive, FromPrimitive};
75 #[doc(no_inline)] pub use boxed::Box;
76 #[doc(no_inline)] pub use path::{GenericPath, Path, PosixPath, WindowsPath};
77 #[doc(no_inline)] pub use ptr::RawPtr;
78 #[doc(no_inline)] pub use io::{Buffer, Writer, Reader, Seek};
79 #[doc(no_inline)] pub use str::{Str, StrVector, StrSlice, OwnedStr};
80 #[doc(no_inline)] pub use str::{IntoMaybeOwned, StrAllocating, UnicodeStrSlice};
81 #[doc(no_inline)] pub use to_str::{ToString, IntoStr};
82 #[doc(no_inline)] pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
83 #[doc(no_inline)] pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
84 #[doc(no_inline)] pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
85 #[doc(no_inline)] pub use slice::{CloneableVector, ImmutableCloneableVector};
86 #[doc(no_inline)] pub use slice::{MutableCloneableVector, MutableOrdVector};
87 #[doc(no_inline)] pub use slice::{ImmutableVector, MutableVector};
88 #[doc(no_inline)] pub use slice::{ImmutableEqVector, ImmutableOrdVector};
89 #[doc(no_inline)] pub use slice::{Vector, VectorVector};
90 #[doc(no_inline)] pub use slice::MutableVectorAllocating;
91 #[doc(no_inline)] pub use string::String;
92 #[doc(no_inline)] pub use vec::Vec;
93
94 // Reexported runtime types
95 #[doc(no_inline)] pub use comm::{sync_channel, channel};
96 #[doc(no_inline)] pub use comm::{SyncSender, Sender, Receiver};
97 #[doc(no_inline)] pub use task::spawn;