]> git.proxmox.com Git - rustc.git/blame - library/std/src/lib.rs
New upstream version 1.65.0+dfsg1
[rustc.git] / library / std / src / lib.rs
CommitLineData
1a4d82fc
JJ
1//! # The Rust Standard Library
2//!
92a42be0
SL
3//! The Rust Standard Library is the foundation of portable Rust software, a
4//! set of minimal and battle-tested shared abstractions for the [broader Rust
5//! ecosystem][crates.io]. It offers core types, like [`Vec<T>`] and
6//! [`Option<T>`], library-defined [operations on language
7//! primitives](#primitives), [standard macros](#macros), [I/O] and
8//! [multithreading], among [many other things][other].
9//!
9fa01778 10//! `std` is available to all Rust crates by default. Therefore, the
92a42be0 11//! standard library can be accessed in [`use`] statements through the path
9fa01778 12//! `std`, as in [`use std::env`].
1a4d82fc 13//!
c1a9b12d 14//! # How to read this documentation
1a4d82fc 15//!
9cc50fc6 16//! If you already know the name of what you are looking for, the fastest way to
92a42be0
SL
17//! find it is to use the <a href="#" onclick="focusSearchBar();">search
18//! bar</a> at the top of the page.
1a4d82fc 19//!
c1a9b12d
SL
20//! Otherwise, you may want to jump to one of these useful sections:
21//!
22//! * [`std::*` modules](#modules)
23//! * [Primitive types](#primitives)
24//! * [Standard macros](#macros)
3dfed10e 25//! * [The Rust Prelude]
c1a9b12d 26//!
92a42be0
SL
27//! If this is your first time, the documentation for the standard library is
28//! written to be casually perused. Clicking on interesting things should
29//! generally lead you to interesting places. Still, there are important bits
30//! you don't want to miss, so read on for a tour of the standard library and
31//! its documentation!
c1a9b12d 32//!
92a42be0
SL
33//! Once you are familiar with the contents of the standard library you may
34//! begin to find the verbosity of the prose distracting. At this stage in your
83c7162d 35//! development you may want to press the `[-]` button near the top of the
92a42be0 36//! page to collapse it into a more skimmable view.
c1a9b12d 37//!
5099ac24
FG
38//! While you are looking at that `[-]` button also notice the `source`
39//! link. Rust's API documentation comes with the source code and you are
92a42be0
SL
40//! encouraged to read it. The standard library source is generally high
41//! quality and a peek behind the curtains is often enlightening.
c1a9b12d
SL
42//!
43//! # What is in the standard library documentation?
44//!
92a42be0
SL
45//! First of all, The Rust Standard Library is divided into a number of focused
46//! modules, [all listed further down this page](#modules). These modules are
47//! the bedrock upon which all of Rust is forged, and they have mighty names
48//! like [`std::slice`] and [`std::cmp`]. Modules' documentation typically
49//! includes an overview of the module along with examples, and are a smart
50//! place to start familiarizing yourself with the library.
c1a9b12d 51//!
92a42be0 52//! Second, implicit methods on [primitive types] are documented here. This can
c1a9b12d
SL
53//! be a source of confusion for two reasons:
54//!
92a42be0
SL
55//! 1. While primitives are implemented by the compiler, the standard library
56//! implements methods directly on the primitive types (and it is the only
57//! library that does so), which are [documented in the section on
58//! primitives](#primitives).
59//! 2. The standard library exports many modules *with the same name as
60//! primitive types*. These define additional items related to the primitive
61//! type, but not the all-important methods.
c1a9b12d
SL
62//!
63//! So for example there is a [page for the primitive type
6a06907d 64//! `i32`](primitive::i32) that lists all the methods that can be called on
92a42be0 65//! 32-bit integers (very useful), and there is a [page for the module
3dfed10e
XL
66//! `std::i32`] that documents the constant values [`MIN`] and [`MAX`] (rarely
67//! useful).
92a42be0 68//!
6a06907d 69//! Note the documentation for the primitives [`str`] and [`[T]`][prim@slice] (also
92a42be0 70//! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
6a06907d 71//! calls to methods on [`str`] and [`[T]`][prim@slice] respectively, via [deref
3b2f2976 72//! coercions][deref-coercions].
92a42be0
SL
73//!
74//! Third, the standard library defines [The Rust Prelude], a small collection
75//! of items - mostly traits - that are imported into every module of every
76//! crate. The traits in the prelude are pervasive, making the prelude
c1a9b12d
SL
77//! documentation a good entry point to learning about the library.
78//!
92a42be0
SL
79//! And finally, the standard library exports a number of standard macros, and
80//! [lists them on this page](#macros) (technically, not all of the standard
81//! macros are defined by the standard library - some are defined by the
82//! compiler - but they are documented here the same). Like the prelude, the
83//! standard macros are imported by default into all crates.
c1a9b12d 84//!
cc61c64b
XL
85//! # Contributing changes to the documentation
86//!
87//! Check out the rust contribution guidelines [here](
29967ef6 88//! https://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation).
3dfed10e
XL
89//! The source for this documentation can be found on
90//! [GitHub](https://github.com/rust-lang/rust).
cc61c64b
XL
91//! To contribute changes, make sure you read the guidelines first, then submit
92//! pull-requests for your suggested changes.
93//!
94//! Contributions are appreciated! If you see a part of the docs that can be
ba9703b0
XL
95//! improved, submit a PR, or chat with us first on [Discord][rust-discord]
96//! #docs.
cc61c64b 97//!
c1a9b12d
SL
98//! # A Tour of The Rust Standard Library
99//!
92a42be0
SL
100//! The rest of this crate documentation is dedicated to pointing out notable
101//! features of The Rust Standard Library.
1a4d82fc 102//!
bd371182 103//! ## Containers and collections
1a4d82fc 104//!
92a42be0
SL
105//! The [`option`] and [`result`] modules define optional and error-handling
106//! types, [`Option<T>`] and [`Result<T, E>`]. The [`iter`] module defines
107//! Rust's iterator trait, [`Iterator`], which works with the [`for`] loop to
108//! access collections.
1a4d82fc 109//!
92a42be0 110//! The standard library exposes three common ways to deal with contiguous
c1a9b12d
SL
111//! regions of memory:
112//!
92a42be0 113//! * [`Vec<T>`] - A heap-allocated *vector* that is resizable at runtime.
6a06907d
XL
114//! * [`[T; N]`][prim@array] - An inline *array* with a fixed size at compile time.
115//! * [`[T]`][prim@slice] - A dynamically sized *slice* into any other kind of contiguous
92a42be0 116//! storage, whether heap-allocated or not.
c1a9b12d 117//!
92a42be0
SL
118//! Slices can only be handled through some kind of *pointer*, and as such come
119//! in many flavors such as:
1a4d82fc 120//!
c1a9b12d
SL
121//! * `&[T]` - *shared slice*
122//! * `&mut [T]` - *mutable slice*
92a42be0 123//! * [`Box<[T]>`][owned slice] - *owned slice*
c1a9b12d 124//!
92a42be0
SL
125//! [`str`], a UTF-8 string slice, is a primitive type, and the standard library
126//! defines many methods for it. Rust [`str`]s are typically accessed as
127//! immutable references: `&str`. Use the owned [`String`] for building and
128//! mutating strings.
1a4d82fc 129//!
92a42be0
SL
130//! For converting to strings use the [`format!`] macro, and for converting from
131//! strings use the [`FromStr`] trait.
1a4d82fc 132//!
92a42be0
SL
133//! Data may be shared by placing it in a reference-counted box or the [`Rc`]
134//! type, and if further contained in a [`Cell`] or [`RefCell`], may be mutated
135//! as well as shared. Likewise, in a concurrent setting it is common to pair an
136//! atomically-reference-counted box, [`Arc`], with a [`Mutex`] to get the same
137//! effect.
bd371182 138//!
92a42be0
SL
139//! The [`collections`] module defines maps, sets, linked lists and other
140//! typical collection types, including the common [`HashMap<K, V>`].
bd371182
AL
141//!
142//! ## Platform abstractions and I/O
1a4d82fc 143//!
92a42be0
SL
144//! Besides basic data types, the standard library is largely concerned with
145//! abstracting over differences in common platforms, most notably Windows and
146//! Unix derivatives.
147//!
148//! Common types of I/O, including [files], [TCP], [UDP], are defined in the
149//! [`io`], [`fs`], and [`net`] modules.
150//!
151//! The [`thread`] module contains Rust's threading abstractions. [`sync`]
152//! contains further primitive shared memory types, including [`atomic`] and
153//! [`mpsc`], which contains the channel types for message passing.
154//!
3dfed10e
XL
155//! [I/O]: io
156//! [`MIN`]: i32::MIN
157//! [`MAX`]: i32::MAX
158//! [page for the module `std::i32`]: crate::i32
159//! [TCP]: net::TcpStream
160//! [The Rust Prelude]: prelude
161//! [UDP]: net::UdpSocket
162//! [`Arc`]: sync::Arc
163//! [owned slice]: boxed
164//! [`Cell`]: cell::Cell
165//! [`FromStr`]: str::FromStr
166//! [`HashMap<K, V>`]: collections::HashMap
167//! [`Mutex`]: sync::Mutex
168//! [`Option<T>`]: option::Option
169//! [`Rc`]: rc::Rc
170//! [`RefCell`]: cell::RefCell
171//! [`Result<T, E>`]: result::Result
172//! [`Vec<T>`]: vec::Vec
173//! [`atomic`]: sync::atomic
13cf67c4 174//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
3dfed10e
XL
175//! [`str`]: prim@str
176//! [`mpsc`]: sync::mpsc
177//! [`std::cmp`]: cmp
5869c6ff 178//! [`std::slice`]: mod@slice
92a42be0 179//! [`use std::env`]: env/index.html
532ac7d7 180//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
92a42be0 181//! [crates.io]: https://crates.io
13cf67c4 182//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
3dfed10e
XL
183//! [files]: fs::File
184//! [multithreading]: thread
92a42be0 185//! [other]: #what-is-in-the-standard-library-documentation
13cf67c4 186//! [primitive types]: ../book/ch03-02-data-types.html
ba9703b0 187//! [rust-discord]: https://discord.gg/rust-lang
6a06907d
XL
188//! [array]: prim@array
189//! [slice]: prim@slice
f2b60f7d 190
3dfed10e
XL
191#![cfg_attr(not(feature = "restricted-std"), stable(feature = "rust1", since = "1.0.0"))]
192#![cfg_attr(feature = "restricted-std", unstable(feature = "restricted_std", issue = "none"))]
dfeec247 193#![doc(
dfeec247
XL
194 html_playground_url = "https://play.rust-lang.org/",
195 issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
196 test(no_crate_inject, attr(deny(warnings))),
197 test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
198)]
5099ac24
FG
199#![doc(cfg_hide(
200 not(test),
201 not(any(test, bootstrap)),
202 no_global_oom_handling,
203 not(no_global_oom_handling)
204))]
f2b60f7d
FG
205// To run libstd tests without x.py without ending up with two copies of libstd, Miri needs to be
206// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
207// rustc itself never sets the feature, so this line has no affect there.
208#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
209// miri-test-libstd also prefers to make std use the sysroot versions of the dependencies.
210#![cfg_attr(feature = "miri-test-libstd", feature(rustc_private))]
c30ab7b3
SL
211// Don't link to std. We are std.
212#![no_std]
f2b60f7d
FG
213// Tell the compiler to link to either panic_abort or panic_unwind
214#![needs_panic_runtime]
215//
216// Lints:
416331ca 217#![warn(deprecated_in_future)]
48663c56
XL
218#![warn(missing_docs)]
219#![warn(missing_debug_implementations)]
532ac7d7 220#![allow(explicit_outlives_requirements)]
416331ca 221#![allow(unused_lifetimes)]
f2b60f7d 222#![deny(rustc::existing_doc_keyword)]
064997fb 223// Ensure that std can be linked against panic_abort despite compiled with `-C panic=unwind`
f2b60f7d 224#![deny(ffi_unwind_calls)]
c30ab7b3
SL
225// std may use features in a platform-specific way
226#![allow(unused_features)]
f2b60f7d
FG
227//
228// Features:
064997fb 229#![cfg_attr(test, feature(internal_output_capture, print_internals, update_panic_count, rt))]
dfeec247
XL
230#![cfg_attr(
231 all(target_vendor = "fortanix", target_env = "sgx"),
3dfed10e 232 feature(slice_index_methods, coerce_unsized, sgx_platform)
dfeec247 233)]
5e7ed085
FG
234//
235// Language features:
8faf50e0 236#![feature(alloc_error_handler)]
041b39d2 237#![feature(allocator_internals)]
3b2f2976 238#![feature(allow_internal_unsafe)]
d9579d0f 239#![feature(allow_internal_unstable)]
1a4d82fc 240#![feature(box_syntax)]
94222f64 241#![feature(c_unwind)]
9cc50fc6 242#![feature(cfg_target_thread_local)]
0731742a 243#![feature(concat_idents)]
a2a8927a 244#![feature(const_mut_refs)]
94222f64 245#![feature(const_trait_impl)]
e74abb32 246#![feature(decl_macro)]
04454e1e 247#![feature(deprecated_suggestion)]
9fa01778 248#![feature(doc_cfg)]
3c0e092e 249#![feature(doc_cfg_hide)]
9fa01778 250#![feature(doc_masked)]
17df50a5 251#![feature(doc_notable_trait)]
32a655c1 252#![feature(dropck_eyepatch)]
9fa01778 253#![feature(exhaustive_patterns)]
6a06907d 254#![feature(intra_doc_pointers)]
f2b60f7d 255#![cfg_attr(bootstrap, feature(label_break_value))]
85aaf69f 256#![feature(lang_items)]
04454e1e 257#![feature(let_chains)]
f2b60f7d 258#![cfg_attr(bootstrap, feature(let_else))]
92a42be0 259#![feature(linkage)]
f2b60f7d 260#![feature(link_cfg)]
3dfed10e 261#![feature(min_specialization)]
3c0e092e 262#![feature(must_not_suspend)]
5bcae85e 263#![feature(needs_panic_runtime)]
f9f354fc 264#![feature(negative_impls)]
cc61c64b 265#![feature(never_type)]
5e7ed085
FG
266#![feature(platform_intrinsics)]
267#![feature(prelude_import)]
268#![feature(rustc_attrs)]
269#![feature(rustdoc_internals)]
270#![feature(staged_api)]
271#![feature(thread_local)]
272#![feature(try_blocks)]
f2b60f7d 273#![feature(utf8_chunks)]
5e7ed085
FG
274//
275// Library features (core):
276#![feature(array_error_internals)]
277#![feature(atomic_mut_ptr)]
278#![feature(char_error_internals)]
279#![feature(char_internals)]
280#![feature(core_intrinsics)]
04454e1e
FG
281#![feature(cstr_from_bytes_until_nul)]
282#![feature(cstr_internals)]
5e7ed085
FG
283#![feature(duration_checked_float)]
284#![feature(duration_constants)]
f2b60f7d
FG
285#![cfg_attr(not(bootstrap), feature(error_generic_member_access))]
286#![cfg_attr(not(bootstrap), feature(error_in_core))]
287#![cfg_attr(not(bootstrap), feature(error_iter))]
5e7ed085 288#![feature(exact_size_is_empty)]
064997fb 289#![feature(exclusive_wrapper)]
5e7ed085
FG
290#![feature(extend_one)]
291#![feature(float_minimum_maximum)]
f2b60f7d 292#![feature(float_next_up_down)]
04454e1e 293#![feature(hasher_prefixfree_extras)]
5e7ed085
FG
294#![feature(hashmap_internals)]
295#![feature(int_error_internals)]
064997fb 296#![feature(is_some_with)]
5e7ed085
FG
297#![feature(maybe_uninit_slice)]
298#![feature(maybe_uninit_write_slice)]
299#![feature(mixed_integer_ops)]
3dfed10e 300#![feature(nonnull_slice_from_raw_parts)]
5e7ed085 301#![feature(panic_can_unwind)]
9fa01778 302#![feature(panic_info_message)]
0531ce1d 303#![feature(panic_internals)]
f2b60f7d
FG
304#![feature(pointer_byte_offsets)]
305#![feature(pointer_is_aligned)]
a2a8927a 306#![feature(portable_simd)]
04454e1e 307#![feature(prelude_2024)]
064997fb 308#![feature(provide_any)]
a2a8927a 309#![feature(ptr_as_uninit)]
5e7ed085 310#![feature(raw_os_nonzero)]
ff7c6d11 311#![feature(slice_internals)]
3dfed10e 312#![feature(slice_ptr_get)]
9fa01778 313#![feature(std_internals)]
62682a34 314#![feature(str_internals)]
5e7ed085 315#![feature(strict_provenance)]
f2b60f7d
FG
316#![feature(maybe_uninit_uninit_array)]
317#![feature(const_maybe_uninit_uninit_array)]
5e7ed085
FG
318//
319// Library features (alloc):
320#![feature(alloc_layout_extra)]
321#![feature(allocator_api)]
322#![feature(get_mut_unchecked)]
323#![feature(map_try_insert)]
324#![feature(new_uninit)]
04454e1e 325#![feature(thin_box)]
94222f64 326#![feature(try_reserve_kind)]
74b04a01 327#![feature(vec_into_raw_parts)]
923072b8 328#![feature(slice_concat_trait)]
5e7ed085
FG
329//
330// Library features (unwind):
331#![feature(panic_unwind)]
332//
333// Only for re-exporting:
334#![feature(assert_matches)]
335#![feature(async_iterator)]
336#![feature(c_variadic)]
337#![feature(cfg_accessible)]
338#![feature(cfg_eval)]
339#![feature(concat_bytes)]
340#![feature(const_format_args)]
5e7ed085
FG
341#![feature(core_panic)]
342#![feature(custom_test_frameworks)]
343#![feature(edition_panic)]
344#![feature(format_args_nl)]
345#![feature(log_syntax)]
346#![feature(once_cell)]
347#![feature(saturating_int_impl)]
348#![feature(stdsimd)]
349#![feature(test)]
350#![feature(trace_macros)]
351//
352// Only used in tests/benchmarks:
353#![feature(bench_black_box)]
354//
355// Only for const-ness:
356#![feature(const_io_structs)]
357#![feature(const_ip)]
358#![feature(const_ipv4)]
359#![feature(const_ipv6)]
5e7ed085
FG
360#![feature(const_socketaddr)]
361#![feature(thread_local_internals)]
362//
3b2f2976
XL
363#![default_lib_allocator]
364
c30ab7b3
SL
365// Explicitly import the prelude. The compiler uses this same unstable attribute
366// to import the prelude implicitly when building crates that depend on std.
9e0c209e
SL
367#[prelude_import]
368#[allow(unused)]
04454e1e 369use prelude::rust_2021::*;
9e0c209e 370
c30ab7b3 371// Access to Bencher, etc.
dfeec247
XL
372#[cfg(test)]
373extern crate test;
1a4d82fc 374
83c7162d 375#[allow(unused_imports)] // macros from `alloc` are not used on all platforms
1a4d82fc 376#[macro_use]
83c7162d 377extern crate alloc as alloc_crate;
ea8adc8c 378#[doc(masked)]
532ac7d7 379#[allow(unused_extern_crates)]
1a4d82fc
JJ
380extern crate libc;
381
a7813a04 382// We always need an unwinder currently for backtraces
ea8adc8c 383#[doc(masked)]
3b2f2976 384#[allow(unused_extern_crates)]
a7813a04
XL
385extern crate unwind;
386
5e7ed085
FG
387#[doc(masked)]
388#[allow(unused_extern_crates)]
389#[cfg(feature = "miniz_oxide")]
390extern crate miniz_oxide;
391
c30ab7b3
SL
392// During testing, this crate is not actually the "real" std library, but rather
393// it links to the real std library, which was compiled from this same source
394// code. So any lang items std defines are conditionally excluded (or else they
83c7162d 395// would generate duplicate lang item errors), and any globals it defines are
c30ab7b3
SL
396// _not_ the globals used by "real" std. So this import, defined only during
397// testing gives test-std access to real-std lang items and globals. See #2912
dfeec247
XL
398#[cfg(test)]
399extern crate std as realstd;
1a4d82fc 400
c30ab7b3
SL
401// The standard macros that are not built-in to the compiler.
402#[macro_use]
403mod macros;
404
5e7ed085
FG
405// The runtime entry point and a few unstable public functions used by the
406// compiler
407#[macro_use]
408pub mod rt;
409
c30ab7b3
SL
410// The Rust prelude
411pub mod prelude;
1a4d82fc 412
2c00a5a8 413// Public module declarations and re-exports
92a42be0 414#[stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
415pub use alloc_crate::borrow;
416#[stable(feature = "rust1", since = "1.0.0")]
417pub use alloc_crate::boxed;
418#[stable(feature = "rust1", since = "1.0.0")]
419pub use alloc_crate::fmt;
420#[stable(feature = "rust1", since = "1.0.0")]
421pub use alloc_crate::format;
422#[stable(feature = "rust1", since = "1.0.0")]
423pub use alloc_crate::rc;
424#[stable(feature = "rust1", since = "1.0.0")]
425pub use alloc_crate::slice;
426#[stable(feature = "rust1", since = "1.0.0")]
427pub use alloc_crate::str;
428#[stable(feature = "rust1", since = "1.0.0")]
429pub use alloc_crate::string;
430#[stable(feature = "rust1", since = "1.0.0")]
431pub use alloc_crate::vec;
432#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 433pub use core::any;
dfeec247
XL
434#[stable(feature = "core_array", since = "1.36.0")]
435pub use core::array;
5099ac24
FG
436#[unstable(feature = "async_iterator", issue = "79024")]
437pub use core::async_iter;
92a42be0 438#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 439pub use core::cell;
92a42be0 440#[stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
441pub use core::char;
442#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 443pub use core::clone;
92a42be0 444#[stable(feature = "rust1", since = "1.0.0")]
c1a9b12d 445pub use core::cmp;
92a42be0 446#[stable(feature = "rust1", since = "1.0.0")]
c34b1796 447pub use core::convert;
92a42be0 448#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 449pub use core::default;
5869c6ff
XL
450#[stable(feature = "futures_api", since = "1.36.0")]
451pub use core::future;
92a42be0 452#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 453pub use core::hash;
dfeec247
XL
454#[stable(feature = "core_hint", since = "1.27.0")]
455pub use core::hint;
456#[stable(feature = "i128", since = "1.26.0")]
5869c6ff 457#[allow(deprecated, deprecated_in_future)]
dfeec247
XL
458pub use core::i128;
459#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 460#[allow(deprecated, deprecated_in_future)]
dfeec247
XL
461pub use core::i16;
462#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 463#[allow(deprecated, deprecated_in_future)]
dfeec247
XL
464pub use core::i32;
465#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 466#[allow(deprecated, deprecated_in_future)]
dfeec247
XL
467pub use core::i64;
468#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 469#[allow(deprecated, deprecated_in_future)]
dfeec247 470pub use core::i8;
92a42be0 471#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 472pub use core::intrinsics;
92a42be0 473#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 474#[allow(deprecated, deprecated_in_future)]
dfeec247
XL
475pub use core::isize;
476#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 477pub use core::iter;
92a42be0 478#[stable(feature = "rust1", since = "1.0.0")]
c1a9b12d 479pub use core::marker;
92a42be0 480#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 481pub use core::mem;
92a42be0 482#[stable(feature = "rust1", since = "1.0.0")]
c1a9b12d 483pub use core::ops;
92a42be0 484#[stable(feature = "rust1", since = "1.0.0")]
dfeec247
XL
485pub use core::option;
486#[stable(feature = "pin", since = "1.33.0")]
487pub use core::pin;
488#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 489pub use core::ptr;
92a42be0 490#[stable(feature = "rust1", since = "1.0.0")]
1a4d82fc 491pub use core::result;
0531ce1d 492#[stable(feature = "i128", since = "1.26.0")]
5869c6ff 493#[allow(deprecated, deprecated_in_future)]
dfeec247 494pub use core::u128;
92a42be0 495#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 496#[allow(deprecated, deprecated_in_future)]
e9174d1e 497pub use core::u16;
92a42be0 498#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 499#[allow(deprecated, deprecated_in_future)]
e9174d1e 500pub use core::u32;
92a42be0 501#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 502#[allow(deprecated, deprecated_in_future)]
e9174d1e 503pub use core::u64;
c30ab7b3 504#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 505#[allow(deprecated, deprecated_in_future)]
dfeec247 506pub use core::u8;
c30ab7b3 507#[stable(feature = "rust1", since = "1.0.0")]
5869c6ff 508#[allow(deprecated, deprecated_in_future)]
dfeec247 509pub use core::usize;
1a4d82fc 510
c30ab7b3
SL
511pub mod f32;
512pub mod f64;
1a4d82fc
JJ
513
514#[macro_use]
c34b1796 515pub mod thread;
c30ab7b3 516pub mod ascii;
e1599b0c 517pub mod backtrace;
c34b1796 518pub mod collections;
c34b1796 519pub mod env;
c30ab7b3 520pub mod error;
1a4d82fc 521pub mod ffi;
85aaf69f 522pub mod fs;
c34b1796 523pub mod io;
85aaf69f 524pub mod net;
c30ab7b3 525pub mod num;
1a4d82fc 526pub mod os;
9cc50fc6 527pub mod panic;
1a4d82fc 528pub mod path;
85aaf69f 529pub mod process;
c34b1796 530pub mod sync;
1a4d82fc 531pub mod time;
83c7162d 532
3dfed10e
XL
533#[unstable(feature = "once_cell", issue = "74465")]
534pub mod lazy;
535
5099ac24
FG
536// Pull in `std_float` crate into libstd. The contents of
537// `std_float` are in a different repository: rust-lang/portable-simd.
538#[path = "../../portable-simd/crates/std_float/src/lib.rs"]
539#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn, unused_unsafe)]
540#[allow(rustdoc::bare_urls)]
541#[unstable(feature = "portable_simd", issue = "86656")]
5099ac24
FG
542mod std_float;
543
5099ac24
FG
544#[doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
545#[unstable(feature = "portable_simd", issue = "86656")]
546pub mod simd {
547 #[doc(inline)]
548 pub use crate::std_float::StdFloat;
549 #[doc(inline)]
550 pub use core::simd::*;
551}
552
48663c56 553#[stable(feature = "futures_api", since = "1.36.0")]
8faf50e0
XL
554pub mod task {
555 //! Types and Traits for working with asynchronous tasks.
ba9703b0 556
8faf50e0 557 #[doc(inline)]
48663c56 558 #[stable(feature = "futures_api", since = "1.36.0")]
8faf50e0 559 pub use core::task::*;
ba9703b0
XL
560
561 #[doc(inline)]
5869c6ff 562 #[stable(feature = "wake_trait", since = "1.51.0")]
ba9703b0 563 pub use alloc::task::*;
8faf50e0
XL
564}
565
5099ac24
FG
566#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
567#[stable(feature = "simd_arch", since = "1.27.0")]
568pub mod arch {
569 #[stable(feature = "simd_arch", since = "1.27.0")]
570 // The `no_inline`-attribute is required to make the documentation of all
571 // targets available.
572 // See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
573 // more information.
574 #[doc(no_inline)] // Note (#82861): required for correct documentation
575 pub use core::arch::*;
576
577 #[stable(feature = "simd_aarch64", since = "1.60.0")]
578 pub use std_detect::is_aarch64_feature_detected;
579 #[stable(feature = "simd_x86", since = "1.27.0")]
580 pub use std_detect::is_x86_feature_detected;
581 #[unstable(feature = "stdsimd", issue = "48556")]
582 pub use std_detect::{
583 is_arm_feature_detected, is_mips64_feature_detected, is_mips_feature_detected,
584 is_powerpc64_feature_detected, is_powerpc_feature_detected, is_riscv_feature_detected,
585 };
586}
587
588// This was stabilized in the crate root so we have to keep it there.
589#[stable(feature = "simd_x86", since = "1.27.0")]
590pub use std_detect::is_x86_feature_detected;
591
c295e0f8 592// Platform-abstraction modules
c30ab7b3 593mod sys;
c295e0f8 594mod sys_common;
1a4d82fc 595
83c7162d
XL
596pub mod alloc;
597
c30ab7b3 598// Private support modules
dfeec247 599mod panicking;
f2b60f7d 600mod personality;
c30ab7b3 601
3dfed10e
XL
602#[path = "../../backtrace/src/lib.rs"]
603#[allow(dead_code, unused_attributes)]
604mod backtrace_rs;
605
416331ca
XL
606// Re-export macros defined in libcore.
607#[stable(feature = "rust1", since = "1.0.0")]
e1599b0c 608#[allow(deprecated, deprecated_in_future)]
416331ca 609pub use core::{
064997fb 610 assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try,
36d6ef2b 611 unimplemented, unreachable, write, writeln,
416331ca
XL
612};
613
614// Re-export built-in macros defined through libcore.
416331ca 615#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
ba9703b0 616#[allow(deprecated)]
416331ca 617pub use core::{
94222f64 618 assert, assert_matches, cfg, column, compile_error, concat, concat_idents, const_format_args,
5099ac24
FG
619 env, file, format_args, format_args_nl, include, include_bytes, include_str, line, log_syntax,
620 module_path, option_env, stringify, trace_macros,
416331ca
XL
621};
622
a2a8927a
XL
623#[unstable(
624 feature = "concat_bytes",
625 issue = "87555",
626 reason = "`concat_bytes` is not stable enough for use and is subject to change"
627)]
a2a8927a
XL
628pub use core::concat_bytes;
629
74b04a01
XL
630#[stable(feature = "core_primitive", since = "1.43.0")]
631pub use core::primitive;
632
c1a9b12d
SL
633// Include a number of private modules that exist solely to provide
634// the rustdoc documentation for primitive types. Using `include!`
635// because rustdoc only looks for these modules at the crate level.
636include!("primitive_docs.rs");
94b46f34
XL
637
638// Include a number of private modules that exist solely to provide
639// the rustdoc documentation for the existing keywords. Using `include!`
640// because rustdoc only looks for these modules at the crate level.
641include!("keyword_docs.rs");
3dfed10e
XL
642
643// This is required to avoid an unstable error when `restricted-std` is not
644// enabled. The use of #![feature(restricted_std)] in rustc-std-workspace-std
645// is unconditional, so the unstable feature needs to be defined somewhere.
fc512014 646#[unstable(feature = "restricted_std", issue = "none")]
3dfed10e 647mod __restricted_std_workaround {}
6a06907d
XL
648
649mod sealed {
650 /// This trait being unreachable from outside the crate
651 /// prevents outside implementations of our extension traits.
652 /// This allows adding more trait methods in the future.
653 #[unstable(feature = "sealed", issue = "none")]
654 pub trait Sealed {}
655}