(index<- ) ./libstd/prelude.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Fri May 9 13:02:28 2014
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 pub use kinds::{Copy, Send, Sized, Share};
42 pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
43 pub use ops::{BitAnd, BitOr, BitXor};
44 pub use ops::{Drop, Deref, DerefMut};
45 pub use ops::{Shl, Shr, Index};
46 pub use option::{Option, Some, None};
47 pub use result::{Result, Ok, Err};
48
49 // Reexported functions
50 pub use from_str::from_str;
51 pub use iter::range;
52 pub use mem::drop;
53
54 // Reexported types and traits
55
56 pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr, IntoBytes};
57 pub use c_str::ToCStr;
58 pub use char::Char;
59 pub use clone::Clone;
60 pub use cmp::{Eq, Ord, TotalEq, TotalOrd, Ordering, Less, Equal, Greater, Equiv};
61 pub use container::{Container, Mutable, Map, MutableMap, Set, MutableSet};
62 pub use iter::{FromIterator, Extendable};
63 pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
64 pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
65 pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul};
66 pub use num::{Signed, Unsigned};
67 pub use num::{Primitive, Int, Float, ToPrimitive, FromPrimitive};
68 pub use option::Expect;
69 pub use owned::Box;
70 pub use path::{GenericPath, Path, PosixPath, WindowsPath};
71 pub use ptr::RawPtr;
72 pub use io::{Buffer, Writer, Reader, Seek};
73 pub use result::{ResultUnwrap, ResultUnwrapErr};
74 pub use str::{Str, StrVector, StrSlice, OwnedStr, IntoMaybeOwned};
75 pub use str::{StrAllocating};
76 pub use to_str::{ToStr, IntoStr};
77 pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
78 pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
79 pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
80 pub use slice::{ImmutableEqVector, ImmutableTotalOrdVector, ImmutableCloneableVector};
81 pub use slice::{OwnedVector};
82 pub use slice::{MutableVector, MutableTotalOrdVector, MutableVectorAllocating};
83 pub use slice::{Vector, VectorVector, CloneableVector, ImmutableVector};
84 pub use strbuf::StrBuf;
85 pub use vec::Vec;
86
87 // Reexported runtime types
88 pub use comm::{sync_channel, channel, SyncSender, Sender, Receiver};
89 pub use task::spawn;
90
91 // Reexported statics
92 #[cfg(not(test))]
93 pub use gc::GC;