]> git.lizzy.rs Git - rust.git/blob - src/liballoc/lib.rs
Separate codepaths for fat and thin LTO in write.rs
[rust.git] / src / liballoc / lib.rs
1 // Copyright 2014-2017 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 core allocation and collections library
12 //!
13 //! This library provides smart pointers and collections for managing
14 //! heap-allocated values.
15 //!
16 //! This library, like libcore, normally doesn’t need to be used directly
17 //! since its contents are re-exported in the [`std` crate](../std/index.html).
18 //! Crates that use the `#![no_std]` attribute however will typically
19 //! not depend on `std`, so they’d use this crate instead.
20 //!
21 //! ## Boxed values
22 //!
23 //! The [`Box`](boxed/index.html) type is a smart pointer type. There can
24 //! only be one owner of a `Box`, and the owner can decide to mutate the
25 //! contents, which live on the heap.
26 //!
27 //! This type can be sent among threads efficiently as the size of a `Box` value
28 //! is the same as that of a pointer. Tree-like data structures are often built
29 //! with boxes because each node often has only one owner, the parent.
30 //!
31 //! ## Reference counted pointers
32 //!
33 //! The [`Rc`](rc/index.html) type is a non-threadsafe reference-counted pointer
34 //! type intended for sharing memory within a thread. An `Rc` pointer wraps a
35 //! type, `T`, and only allows access to `&T`, a shared reference.
36 //!
37 //! This type is useful when inherited mutability (such as using `Box`) is too
38 //! constraining for an application, and is often paired with the `Cell` or
39 //! `RefCell` types in order to allow mutation.
40 //!
41 //! ## Atomically reference counted pointers
42 //!
43 //! The [`Arc`](sync/index.html) type is the threadsafe equivalent of the `Rc`
44 //! type. It provides all the same functionality of `Rc`, except it requires
45 //! that the contained type `T` is shareable. Additionally, `Arc<T>` is itself
46 //! sendable while `Rc<T>` is not.
47 //!
48 //! This type allows for shared access to the contained data, and is often
49 //! paired with synchronization primitives such as mutexes to allow mutation of
50 //! shared resources.
51 //!
52 //! ## Collections
53 //!
54 //! Implementations of the most common general purpose data structures are
55 //! defined in this library. They are re-exported through the
56 //! [standard collections library](../std/collections/index.html).
57 //!
58 //! ## Heap interfaces
59 //!
60 //! The [`alloc`](alloc/index.html) module defines the low-level interface to the
61 //! default global allocator. It is not compatible with the libc allocator API.
62
63 #![allow(unused_attributes)]
64 #![unstable(feature = "alloc",
65             reason = "this library is unlikely to be stabilized in its current \
66                       form or name",
67             issue = "27783")]
68 #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
69        html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
70        html_root_url = "https://doc.rust-lang.org/nightly/",
71        issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
72        test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
73 #![no_std]
74 #![needs_allocator]
75 #![deny(missing_debug_implementations)]
76
77 #![cfg_attr(not(test), feature(fn_traits))]
78 #![cfg_attr(not(test), feature(generator_trait))]
79 #![cfg_attr(test, feature(test))]
80
81 #![feature(allocator_api)]
82 #![feature(allow_internal_unstable)]
83 #![feature(arbitrary_self_types)]
84 #![feature(box_into_raw_non_null)]
85 #![feature(box_patterns)]
86 #![feature(box_syntax)]
87 #![feature(cfg_target_has_atomic)]
88 #![feature(coerce_unsized)]
89 #![feature(dispatch_from_dyn)]
90 #![feature(core_intrinsics)]
91 #![feature(custom_attribute)]
92 #![feature(dropck_eyepatch)]
93 #![feature(exact_size_is_empty)]
94 #![feature(fmt_internals)]
95 #![feature(fundamental)]
96 #![feature(futures_api)]
97 #![feature(lang_items)]
98 #![feature(libc)]
99 #![feature(needs_allocator)]
100 #![feature(nll)]
101 #![feature(optin_builtin_traits)]
102 #![feature(pattern)]
103 #![feature(pin)]
104 #![feature(ptr_internals)]
105 #![feature(ptr_offset_from)]
106 #![feature(rustc_attrs)]
107 #![feature(specialization)]
108 #![feature(split_ascii_whitespace)]
109 #![feature(staged_api)]
110 #![feature(str_internals)]
111 #![feature(trusted_len)]
112 #![feature(try_reserve)]
113 #![feature(unboxed_closures)]
114 #![feature(unicode_internals)]
115 #![feature(unsize)]
116 #![feature(allocator_internals)]
117 #![feature(on_unimplemented)]
118 #![feature(rustc_const_unstable)]
119 #![feature(const_vec_new)]
120 #![feature(slice_partition_dedup)]
121 #![feature(maybe_uninit)]
122 #![feature(alloc_layout_extra)]
123
124 // Allow testing this library
125
126 #[cfg(test)]
127 #[macro_use]
128 extern crate std;
129 #[cfg(test)]
130 extern crate test;
131 #[cfg(test)]
132 extern crate rand;
133
134 // Module with internal macros used by other modules (needs to be included before other modules).
135 #[macro_use]
136 mod macros;
137
138 // Heaps provided for low-level allocation strategies
139
140 pub mod alloc;
141
142 #[unstable(feature = "futures_api",
143            reason = "futures in libcore are unstable",
144            issue = "50547")]
145 pub mod task;
146 // Primitive types using the heaps above
147
148 // Need to conditionally define the mod from `boxed.rs` to avoid
149 // duplicating the lang-items when building in test cfg; but also need
150 // to allow code to have `use boxed::Box;` declarations.
151 #[cfg(not(test))]
152 pub mod boxed;
153 #[cfg(test)]
154 mod boxed {
155     pub use std::boxed::Box;
156 }
157 #[cfg(test)]
158 mod boxed_test;
159 pub mod collections;
160 #[cfg(all(target_has_atomic = "ptr", target_has_atomic = "cas"))]
161 pub mod sync;
162 pub mod rc;
163 pub mod raw_vec;
164 pub mod prelude;
165 pub mod borrow;
166 pub mod fmt;
167 pub mod slice;
168 pub mod str;
169 pub mod string;
170 pub mod vec;
171
172 #[cfg(not(test))]
173 mod std {
174     pub use core::ops;      // RangeFull
175 }