]> git.lizzy.rs Git - rust.git/blob - src/libstd/prelude/mod.rs
Update the doc for std::prelude, removing the "technical part" section
[rust.git] / src / libstd / prelude / mod.rs
1 //! The Rust Prelude.
2 //!
3 //! Rust comes with a variety of things in its standard library. However, if
4 //! you had to manually import every single thing that you used, it would be
5 //! very verbose. But importing a lot of things that a program never uses isn't
6 //! good either. A balance needs to be struck.
7 //!
8 //! The *prelude* is the list of things that Rust automatically imports into
9 //! every Rust program. It's kept as small as possible, and is focused on
10 //! things, particularly traits, which are used in almost every single Rust
11 //! program.
12 //!
13 //! # Other preludes
14 //!
15 //! Preludes can be seen as a pattern to make using multiple types more
16 //! convenient. As such, you'll find other preludes in the standard library,
17 //! such as [`std::io::prelude`]. Various libraries in the Rust ecosystem may
18 //! also define their own preludes.
19 //!
20 //! [`std::io::prelude`]: ../io/prelude/index.html
21 //!
22 //! The difference between 'the prelude' and these other preludes is that they
23 //! are not automatically `use`'d, and must be imported manually. This is still
24 //! easier than importing all of their constituent components.
25 //!
26 //! # Prelude contents
27 //!
28 //! The current version of the prelude (version 1) lives in
29 //! [`std::prelude::v1`], and re-exports the following.
30 //!
31 //! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]}. The
32 //!   marker traits indicate fundamental properties of types.
33 //! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}. Various
34 //!   operations for both destructors and overloading `()`.
35 //! * [`std::mem`]::[`drop`][`mem::drop`], a convenience function for explicitly
36 //!   dropping a value.
37 //! * [`std::boxed`]::[`Box`], a way to allocate values on the heap.
38 //! * [`std::borrow`]::[`ToOwned`], The conversion trait that defines
39 //!   [`to_owned`], the generic method for creating an owned type from a
40 //!   borrowed type.
41 //! * [`std::clone`]::[`Clone`], the ubiquitous trait that defines
42 //!   [`clone`][`Clone::clone`], the method for producing a copy of a value.
43 //! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`] }. The
44 //!   comparison traits, which implement the comparison operators and are often
45 //!   seen in trait bounds.
46 //! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}. Generic
47 //!   conversions, used by savvy API authors to create overloaded methods.
48 //! * [`std::default`]::[`Default`], types that have default values.
49 //! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`],
50 //!   [`DoubleEndedIterator`], [`ExactSizeIterator`]}. Iterators of various
51 //!   kinds.
52 //! * [`std::option`]::[`Option`]::{`self`, `Some`, `None`}. A type which
53 //!   expresses the presence or absence of a value. This type is so commonly
54 //!   used, its variants are also exported.
55 //! * [`std::result`]::[`Result`]::{`self`, `Ok`, `Err`}. A type for functions
56 //!   that may succeed or fail. Like [`Option`], its variants are exported as
57 //!   well.
58 //! * [`std::string`]::{[`String`], [`ToString`]}, heap allocated strings.
59 //! * [`std::vec`]::[`Vec`](../vec/struct.Vec.html), a growable, heap-allocated
60 //!   vector.
61 //!
62 //! [`AsMut`]: ../convert/trait.AsMut.html
63 //! [`AsRef`]: ../convert/trait.AsRef.html
64 //! [`Box`]: ../boxed/struct.Box.html
65 //! [`Clone`]: ../clone/trait.Clone.html
66 //! [`Copy`]: ../marker/trait.Copy.html
67 //! [`Default`]: ../default/trait.Default.html
68 //! [`DoubleEndedIterator`]: ../iter/trait.DoubleEndedIterator.html
69 //! [`Drop`]: ../ops/trait.Drop.html
70 //! [`Eq`]: ../cmp/trait.Eq.html
71 //! [`ExactSizeIterator`]: ../iter/trait.ExactSizeIterator.html
72 //! [`Extend`]: ../iter/trait.Extend.html
73 //! [`FnMut`]: ../ops/trait.FnMut.html
74 //! [`FnOnce`]: ../ops/trait.FnOnce.html
75 //! [`Fn`]: ../ops/trait.Fn.html
76 //! [`From`]: ../convert/trait.From.html
77 //! [`IntoIterator`]: ../iter/trait.IntoIterator.html
78 //! [`Into`]: ../convert/trait.Into.html
79 //! [`Iterator`]: ../iter/trait.Iterator.html
80 //! [`Option`]: ../option/enum.Option.html
81 //! [`Ord`]: ../cmp/trait.Ord.html
82 //! [`PartialEq`]: ../cmp/trait.PartialEq.html
83 //! [`PartialOrd`]: ../cmp/trait.PartialOrd.html
84 //! [`Result`]: ../result/enum.Result.html
85 //! [`Send`]: ../marker/trait.Send.html
86 //! [`Sized`]: ../marker/trait.Sized.html
87 //! [`SliceConcatExt`]: ../slice/trait.SliceConcatExt.html
88 //! [`String`]: ../string/struct.String.html
89 //! [`Sync`]: ../marker/trait.Sync.html
90 //! [`ToOwned`]: ../borrow/trait.ToOwned.html
91 //! [`ToString`]: ../string/trait.ToString.html
92 //! [`Unpin`]: ../marker/trait.Unpin.html
93 //! [`Vec`]: ../vec/struct.Vec.html
94 //! [`Clone::clone`]: ../clone/trait.Clone.html#tymethod.clone
95 //! [`mem::drop`]: ../mem/fn.drop.html
96 //! [`std::borrow`]: ../borrow/index.html
97 //! [`std::boxed`]: ../boxed/index.html
98 //! [`std::clone`]: ../clone/index.html
99 //! [`std::cmp`]: ../cmp/index.html
100 //! [`std::convert`]: ../convert/index.html
101 //! [`std::default`]: ../default/index.html
102 //! [`std::iter`]: ../iter/index.html
103 //! [`std::marker`]: ../marker/index.html
104 //! [`std::mem`]: ../mem/index.html
105 //! [`std::ops`]: ../ops/index.html
106 //! [`std::option`]: ../option/index.html
107 //! [`std::prelude::v1`]: v1/index.html
108 //! [`std::result`]: ../result/index.html
109 //! [`std::slice`]: ../slice/index.html
110 //! [`std::string`]: ../string/index.html
111 //! [`std::vec`]: ../vec/index.html
112 //! [`to_owned`]: ../borrow/trait.ToOwned.html#tymethod.to_owned
113 //! [book-closures]: ../../book/ch13-01-closures.html
114 //! [book-dtor]: ../../book/ch15-03-drop.html
115 //! [book-enums]: ../../book/ch06-01-defining-an-enum.html
116 //! [book-iter]: ../../book/ch13-02-iterators.html
117
118 #![stable(feature = "rust1", since = "1.0.0")]
119
120 pub mod v1;