Skip to main content

std/
lib.rs

1//! **You are viewing the documentation of the Rust standard library as a part
2//! of the Fortanix Rust EDP.** The only changes compared to the normal Rust
3//! standard library are the addition of the [`std::os::fortanix_sgx` module].
4//!
5//! [`std::os::fortanix_sgx` module]: os/fortanix_sgx/
6//!
7//! ---
8//!
9//! # The Rust Standard Library
10//!
11//! The Rust Standard Library is the foundation of portable Rust software, a
12//! set of minimal and battle-tested shared abstractions for the [broader Rust
13//! ecosystem][crates.io]. It offers core types, like [`Vec<T>`] and
14//! [`Option<T>`], library-defined [operations on language
15//! primitives](#primitives), [standard macros](#macros), [I/O] and
16//! [multithreading], among [many other things][other].
17//!
18//! `std` is available to all Rust crates by default. Therefore, the
19//! standard library can be accessed in [`use`] statements through the path
20//! `std`, as in [`use std::env`].
21//!
22//! # How to read this documentation
23//!
24//! If you already know the name of what you are looking for, the fastest way to
25//! find it is to use the <a href="#" onclick="window.searchState.focus();">search
26//! button</a> at the top of the page.
27//!
28//! Otherwise, you may want to jump to one of these useful sections:
29//!
30//! * [`std::*` modules](#modules)
31//! * [Primitive types](#primitives)
32//! * [Standard macros](#macros)
33//! * [The Rust Prelude]
34//!
35//! If this is your first time, the documentation for the standard library is
36//! written to be casually perused. Clicking on interesting things should
37//! generally lead you to interesting places. Still, there are important bits
38//! you don't want to miss, so read on for a tour of the standard library and
39//! its documentation!
40//!
41//! Once you are familiar with the contents of the standard library you may
42//! begin to find the verbosity of the prose distracting. At this stage in your
43//! development you may want to press the
44//! "<svg style="width:0.75rem;height:0.75rem" viewBox="0 0 12 12" stroke="currentColor" fill="none"><path d="M2,2l4,4l4,-4M2,6l4,4l4,-4"/></svg>&nbsp;Summary"
45//! button near the top of the page to collapse it into a more skimmable view.
46//!
47//! While you are looking at the top of the page, also notice the
48//! "Source" link. Rust's API documentation comes with the source
49//! code and you are encouraged to read it. The standard library source is
50//! generally high quality and a peek behind the curtains is
51//! often enlightening.
52//!
53//! # What is in the standard library documentation?
54//!
55//! First of all, The Rust Standard Library is divided into a number of focused
56//! modules, [all listed further down this page](#modules). These modules are
57//! the bedrock upon which all of Rust is forged, and they have mighty names
58//! like [`std::slice`] and [`std::cmp`]. Modules' documentation typically
59//! includes an overview of the module along with examples, and are a smart
60//! place to start familiarizing yourself with the library.
61//!
62//! Second, implicit methods on [primitive types] are documented here. This can
63//! be a source of confusion for two reasons:
64//!
65//! 1. While primitives are implemented by the compiler, the standard library
66//!    implements methods directly on the primitive types (and it is the only
67//!    library that does so), which are [documented in the section on
68//!    primitives](#primitives).
69//! 2. The standard library exports many modules *with the same name as
70//!    primitive types*. These define additional items related to the primitive
71//!    type, but not the all-important methods.
72//!
73//! So for example there is a [page for the primitive type
74//! `char`](primitive::char) that lists all the methods that can be called on
75//! characters (very useful), and there is a [page for the module
76//! `std::char`](crate::char) that documents iterator and error types created by these methods
77//! (rarely useful).
78//!
79//! Note the documentation for the primitives [`str`] and [`[T]`][prim@slice] (also
80//! called 'slice'). Many method calls on [`String`] and [`Vec<T>`] are actually
81//! calls to methods on [`str`] and [`[T]`][prim@slice] respectively, via [deref
82//! coercions][deref-coercions].
83//!
84//! Third, the standard library defines [The Rust Prelude], a small collection
85//! of items - mostly traits - that are imported into every module of every
86//! crate. The traits in the prelude are pervasive, making the prelude
87//! documentation a good entry point to learning about the library.
88//!
89//! And finally, the standard library exports a number of standard macros, and
90//! [lists them on this page](#macros) (technically, not all of the standard
91//! macros are defined by the standard library - some are defined by the
92//! compiler - but they are documented here the same). Like the prelude, the
93//! standard macros are imported by default into all crates.
94//!
95//! # Contributing changes to the documentation
96//!
97//! Check out the Rust contribution guidelines [here](
98//! https://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation).
99//! The source for this documentation can be found on
100//! [GitHub](https://github.com/rust-lang/rust) in the 'library/std/' directory.
101//! To contribute changes, make sure you read the guidelines first, then submit
102//! pull-requests for your suggested changes.
103//!
104//! Contributions are appreciated! If you see a part of the docs that can be
105//! improved, submit a PR, or chat with us first on [Zulip][t-libs-zulip]
106//! #t-libs.
107//!
108//! # A Tour of The Rust Standard Library
109//!
110//! The rest of this crate documentation is dedicated to pointing out notable
111//! features of The Rust Standard Library.
112//!
113//! ## Containers and collections
114//!
115//! The [`option`] and [`result`] modules define optional and error-handling
116//! types, [`Option<T>`] and [`Result<T, E>`]. The [`iter`] module defines
117//! Rust's iterator trait, [`Iterator`], which works with the [`for`] loop to
118//! access collections.
119//!
120//! The standard library exposes three common ways to deal with contiguous
121//! regions of memory:
122//!
123//! * [`Vec<T>`] - A heap-allocated *vector* that is resizable at runtime.
124//! * [`[T; N]`][prim@array] - An inline *array* with a fixed size at compile time.
125//! * [`[T]`][prim@slice] - A dynamically sized *slice* into any other kind of contiguous
126//!   storage, whether heap-allocated or not.
127//!
128//! Slices can only be handled through some kind of *pointer*, and as such come
129//! in many flavors such as:
130//!
131//! * `&[T]` - *shared slice*
132//! * `&mut [T]` - *mutable slice*
133//! * [`Box<[T]>`][owned slice] - *owned slice*
134//!
135//! [`str`], a UTF-8 string slice, is a primitive type, and the standard library
136//! defines many methods for it. Rust [`str`]s are typically accessed as
137//! immutable references: `&str`. Use the owned [`String`] for building and
138//! mutating strings.
139//!
140//! For converting to strings use the [`format!`] macro, and for converting from
141//! strings use the [`FromStr`] trait.
142//!
143//! Data may be shared by placing it in a reference-counted box or the [`Rc`]
144//! type, and if further contained in a [`Cell`] or [`RefCell`], may be mutated
145//! as well as shared. Likewise, in a concurrent setting it is common to pair an
146//! atomically-reference-counted box, [`Arc`], with a [`Mutex`] to get the same
147//! effect.
148//!
149//! The [`collections`] module defines maps, sets, linked lists and other
150//! typical collection types, including the common [`HashMap<K, V>`].
151//!
152//! ## Platform abstractions and I/O
153//!
154//! Besides basic data types, the standard library is largely concerned with
155//! abstracting over differences in common platforms, most notably Windows and
156//! Unix derivatives.
157//!
158//! Common types of I/O, including [files], [TCP], and [UDP], are defined in
159//! the [`io`], [`fs`], and [`net`] modules.
160//!
161//! The [`thread`] module contains Rust's threading abstractions. [`sync`]
162//! contains further primitive shared memory types, including [`atomic`], [`mpmc`] and
163//! [`mpsc`], which contains the channel types for message passing.
164//!
165//! # Use before and after `main()`
166//!
167//! Many parts of the standard library are expected to work before and after `main()`;
168//! but this is not guaranteed or ensured by tests. It is recommended that you write your own tests
169//! and run them on each platform you wish to support.
170//! This means that use of `std` before/after main, especially of features that interact with the
171//! OS or global state, is exempted from stability and portability guarantees and instead only
172//! provided on a best-effort basis. Nevertheless bug reports are appreciated.
173//!
174//! On the other hand `core` and `alloc` are most likely to work in such environments with
175//! the caveat that any hookable behavior such as panics, oom handling or allocators will also
176//! depend on the compatibility of the hooks.
177//!
178//! Some features may also behave differently outside main, e.g. stdio could become unbuffered,
179//! some panics might turn into aborts, backtraces might not get symbolicated or similar.
180//!
181//! Non-exhaustive list of known limitations:
182//!
183//! - after-main use of thread-locals, which also affects additional features:
184//!   - [`thread::current()`]
185//! - under UNIX, before main, file descriptors 0, 1, and 2 may be unchanged
186//!   (they are guaranteed to be open during main,
187//!    and are opened to /dev/null O_RDWR if they weren't open on program start)
188//!
189//!
190//! [I/O]: io
191//! [TCP]: net::TcpStream
192//! [The Rust Prelude]: prelude
193//! [UDP]: net::UdpSocket
194//! [`Arc`]: sync::Arc
195//! [owned slice]: boxed
196//! [`Cell`]: cell::Cell
197//! [`FromStr`]: str::FromStr
198//! [`HashMap<K, V>`]: collections::HashMap
199//! [`Mutex`]: sync::Mutex
200//! [`Option<T>`]: option::Option
201//! [`Rc`]: rc::Rc
202//! [`RefCell`]: cell::RefCell
203//! [`Result<T, E>`]: result::Result
204//! [`Vec<T>`]: vec::Vec
205//! [`atomic`]: sync::atomic
206//! [`for`]: ../book/ch03-05-control-flow.html#looping-through-a-collection-with-for
207//! [`str`]: prim@str
208//! [`mpmc`]: sync::mpmc
209//! [`mpsc`]: sync::mpsc
210//! [`std::cmp`]: cmp
211//! [`std::slice`]: mod@slice
212//! [`use std::env`]: env/index.html
213//! [`use`]: ../book/ch07-02-defining-modules-to-control-scope-and-privacy.html
214//! [crates.io]: https://crates.io
215//! [deref-coercions]: ../book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods
216//! [files]: fs::File
217//! [multithreading]: thread
218//! [other]: #what-is-in-the-standard-library-documentation
219//! [primitive types]: ../book/ch03-02-data-types.html
220//! [t-libs-zulip]: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/
221//! [array]: prim@array
222//! [slice]: prim@slice
223
224#![cfg_attr(not(restricted_std), stable(feature = "rust1", since = "1.0.0"))]
225#![cfg_attr(
226    restricted_std,
227    unstable(
228        feature = "restricted_std",
229        issue = "none",
230        reason = "You have attempted to use a standard library built for a platform that it doesn't \
231            know how to support. Consider building it for a known environment, disabling it with \
232            `#![no_std]` or overriding this warning by enabling this feature."
233    )
234)]
235#![rustc_preserve_ub_checks]
236#![doc(
237    html_root_url = "https://edp.fortanix.com/docs/api/",
238    html_logo_url = "https://edp.fortanix.com/img/docs/edp-logo.svg",
239    html_favicon_url = "https://edp.fortanix.com/favicon.ico",
240    html_playground_url = "https://play.rust-lang.org/",
241    issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
242    test(no_crate_inject, attr(deny(warnings))),
243    test(attr(allow(dead_code, deprecated, unused_variables, unused_mut)))
244)]
245#![doc(rust_logo)]
246#![doc(auto_cfg(hide(no_global_oom_handling)))]
247// Don't link to std. We are std.
248#![no_std]
249// Tell the compiler to link to either panic_abort or panic_unwind
250#![needs_panic_runtime]
251//
252// Lints:
253#![warn(deprecated_in_future)]
254#![warn(missing_docs)]
255#![warn(unreachable_pub)]
256#![warn(missing_debug_implementations)]
257#![allow(explicit_outlives_requirements)]
258#![allow(internal_features)]
259#![deny(implicit_provenance_casts)]
260#![deny(unsafe_op_in_unsafe_fn)]
261#![allow(rustdoc::redundant_explicit_links)]
262#![warn(rustdoc::unescaped_backticks)]
263// Ensure that std can be linked against panic_abort despite compiled with `-C panic=unwind`
264#![deny(ffi_unwind_calls)]
265// std may use features in a platform-specific way
266#![allow(unused_features)]
267//
268// Features:
269#![cfg_attr(
270    test,
271    feature(internal_output_capture, print_internals, super_let, update_panic_count, rt)
272)]
273#![cfg_attr(
274    all(target_vendor = "fortanix", target_env = "sgx"),
275    feature(slice_index_methods, coerce_unsized, sgx_platform)
276)]
277#![cfg_attr(all(test, target_os = "uefi"), feature(uefi_std))]
278#![cfg_attr(target_family = "wasm", feature(stdarch_wasm_atomic_wait))]
279#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
280//
281// Language features:
282// tidy-alphabetical-start
283#![feature(alloc_error_handler)]
284#![feature(allocator_internals)]
285#![feature(allow_internal_unsafe)]
286#![feature(allow_internal_unstable)]
287#![feature(asm_experimental_arch)]
288#![feature(autodiff)]
289#![feature(cfg_sanitizer_cfi)]
290#![feature(cfg_target_has_threads)]
291#![feature(cfg_target_thread_local)]
292#![feature(cfi_encoding)]
293#![feature(const_trait_impl)]
294#![feature(decl_macro)]
295#![feature(deprecated_suggestion)]
296#![feature(diagnostic_on_move)]
297#![feature(doc_cfg)]
298#![feature(doc_masked)]
299#![feature(doc_notable_trait)]
300#![feature(dropck_eyepatch)]
301#![feature(exact_div)]
302#![feature(f16)]
303#![feature(f128)]
304#![feature(ffi_const)]
305#![feature(gpu_offload)]
306#![feature(impl_restriction)]
307#![feature(intra_doc_pointers)]
308#![feature(lang_items)]
309#![feature(link_cfg)]
310#![feature(linkage)]
311#![feature(macro_metavar_expr_concat)]
312#![feature(min_specialization)]
313#![feature(must_not_suspend)]
314#![feature(needs_panic_runtime)]
315#![feature(negative_impls)]
316#![feature(prelude_import)]
317#![feature(rustc_attrs)]
318#![feature(rustdoc_internals)]
319#![feature(staged_api)]
320#![feature(stmt_expr_attributes)]
321#![feature(strict_provenance_lints)]
322#![feature(thread_local)]
323#![feature(try_blocks)]
324#![feature(try_trait_v2)]
325#![feature(type_alias_impl_trait)]
326// tidy-alphabetical-end
327//
328// Library features (core):
329// tidy-alphabetical-start
330#![feature(borrowed_buf_init)]
331#![feature(byte_str)]
332#![feature(byte_str_internals)]
333#![feature(c_size_t)]
334#![feature(can_vector)]
335#![feature(cast_maybe_uninit)]
336#![feature(char_internals)]
337#![feature(clone_to_uninit)]
338#![feature(const_clone)]
339#![feature(const_convert)]
340#![feature(const_default)]
341#![feature(core_float_math)]
342#![feature(core_intrinsics)]
343#![feature(core_io)]
344#![feature(core_io_borrowed_buf)]
345#![feature(core_io_internals)]
346#![feature(cursor_split)]
347#![feature(derive_const)]
348#![feature(duration_constants)]
349#![feature(error_generic_member_access)]
350#![feature(error_iter)]
351#![feature(exact_size_is_empty)]
352#![feature(extend_one)]
353#![feature(float_gamma)]
354#![feature(float_minimum_maximum)]
355#![feature(fmt_internals)]
356#![feature(fn_static)]
357#![feature(formatting_options)]
358#![feature(generic_atomic)]
359#![feature(hash_map_internals)]
360#![feature(hash_map_macro)]
361#![feature(hasher_prefixfree_extras)]
362#![feature(hashmap_internals)]
363#![feature(hint_must_use)]
364#![feature(int_from_ascii)]
365#![feature(io_error_inprogress)]
366#![feature(io_error_input_output_error)]
367#![feature(io_error_more)]
368#![feature(io_error_too_many_open_files)]
369#![feature(io_error_uncategorized)]
370#![feature(io_slice_as_bytes)]
371#![feature(ip)]
372#![feature(ipv6_hop_limit)]
373#![feature(iter_advance_by)]
374#![feature(iter_next_chunk)]
375#![feature(maybe_dangling)]
376#![feature(maybe_uninit_array_assume_init)]
377#![feature(maybe_uninit_fill)]
378#![feature(once_lazy_lock_get_unchecked)]
379#![feature(panic_can_unwind)]
380#![feature(panic_internals)]
381#![feature(pin_coerce_unsized_trait)]
382#![feature(pointer_is_aligned_to)]
383#![feature(portable_simd)]
384#![feature(ptr_as_uninit)]
385#![feature(ptr_cast_slice)]
386#![feature(ptr_mask)]
387#![feature(random)]
388#![feature(raw_os_error_ty)]
389#![feature(seek_io_take_position)]
390#![feature(seek_stream_len)]
391#![feature(share_trait)]
392#![feature(slice_internals)]
393#![feature(slice_ptr_get)]
394#![feature(slice_range)]
395#![feature(slice_split_once)]
396#![feature(std_internals)]
397#![feature(str_internals)]
398#![feature(sync_unsafe_cell)]
399#![feature(temporary_niche_types)]
400#![feature(ub_checks)]
401#![feature(uint_carryless_mul)]
402#![feature(unsafe_pinned)]
403#![feature(used_with_arg)]
404#![feature(write_all_vectored)]
405// tidy-alphabetical-end
406//
407// Library features (alloc):
408// tidy-alphabetical-start
409#![feature(alloc_io)]
410#![feature(allocator_ext)]
411#![feature(buf_read_has_data_left)]
412#![feature(clone_from_ref)]
413#![feature(get_mut_unchecked)]
414#![feature(map_try_insert)]
415#![feature(read_buf)]
416#![feature(slice_concat_trait)]
417#![feature(thin_box)]
418#![feature(try_reserve_kind)]
419#![feature(try_with_capacity)]
420#![feature(unique_rc_arc)]
421#![feature(wtf8_internals)]
422// tidy-alphabetical-end
423//
424// Library features (unwind):
425// tidy-alphabetical-start
426#![feature(panic_unwind)]
427// tidy-alphabetical-end
428//
429// Library features (std_detect):
430// tidy-alphabetical-start
431#![feature(stdarch_internal)]
432// tidy-alphabetical-end
433//
434// Only for re-exporting:
435// tidy-alphabetical-start
436#![feature(async_iterator)]
437#![feature(cfg_accessible)]
438#![feature(cfg_eval)]
439#![feature(concat_bytes)]
440#![feature(const_format_args)]
441#![feature(custom_test_frameworks)]
442#![feature(edition_panic)]
443#![feature(format_args_nl)]
444#![feature(log_syntax)]
445#![feature(test)]
446#![feature(trace_macros)]
447// tidy-alphabetical-end
448//
449// Only used in tests/benchmarks:
450//
451// Only for const-ness:
452// tidy-alphabetical-start
453#![feature(io_const_error)]
454// tidy-alphabetical-end
455//
456#![default_lib_allocator]
457// Removed features
458#![unstable_removed(
459    feature = "concat_idents",
460    reason = "Replaced by the macro_metavar_expr_concat feature",
461    link = "https://github.com/rust-lang/rust/issues/29599#issuecomment-2986866250",
462    since = "1.90.0"
463)]
464
465// The Rust prelude
466// The compiler expects the prelude definition to be defined before its use statement.
467pub mod prelude;
468
469// Explicitly import the prelude. The compiler uses this same unstable attribute
470// to import the prelude implicitly when building crates that depend on std.
471#[prelude_import]
472#[allow(unused)]
473use prelude::rust_2024::*;
474
475// Access to Bencher, etc.
476#[cfg(test)]
477extern crate test;
478
479#[allow(unused_imports)] // macros from `alloc` are not used on all platforms
480#[macro_use]
481extern crate alloc as alloc_crate;
482
483// Many compiler tests depend on libc being pulled in by std
484// so include it here even if it's unused.
485#[doc(masked)]
486#[allow(unused_extern_crates)]
487#[cfg(not(all(windows, target_env = "msvc")))]
488extern crate libc;
489
490// We always need an unwinder currently for backtraces
491#[doc(masked)]
492#[allow(unused_extern_crates)]
493extern crate unwind;
494
495// FIXME: #94122 this extern crate definition only exist here to stop
496// miniz_oxide docs leaking into std docs. Find better way to do it.
497// Remove exclusion from tidy platform check when this removed.
498#[doc(masked)]
499#[allow(unused_extern_crates)]
500#[cfg(all(
501    not(all(windows, target_env = "msvc", not(target_vendor = "uwp"))),
502    feature = "miniz_oxide"
503))]
504extern crate miniz_oxide;
505
506// During testing, this crate is not actually the "real" std library, but rather
507// it links to the real std library, which was compiled from this same source
508// code. So any lang items std defines are conditionally excluded (or else they
509// would generate duplicate lang item errors), and any globals it defines are
510// _not_ the globals used by "real" std. So this import, defined only during
511// testing gives test-std access to real-std lang items and globals. See #2912
512#[cfg(test)]
513extern crate std as realstd;
514
515// The standard macros that are not built-in to the compiler.
516#[macro_use]
517mod macros;
518
519// The runtime entry point and a few unstable public functions used by the
520// compiler
521#[macro_use]
522pub mod rt;
523
524#[stable(feature = "rust1", since = "1.0.0")]
525pub use core::any;
526#[stable(feature = "core_array", since = "1.35.0")]
527pub use core::array;
528#[unstable(feature = "async_iterator", issue = "79024")]
529pub use core::async_iter;
530#[stable(feature = "rust1", since = "1.0.0")]
531pub use core::cell;
532#[stable(feature = "rust1", since = "1.0.0")]
533pub use core::char;
534#[stable(feature = "rust1", since = "1.0.0")]
535pub use core::clone;
536#[stable(feature = "rust1", since = "1.0.0")]
537pub use core::cmp;
538#[stable(feature = "rust1", since = "1.0.0")]
539pub use core::convert;
540#[stable(feature = "rust1", since = "1.0.0")]
541pub use core::default;
542#[unstable(feature = "field_projections", issue = "145383")]
543pub use core::field;
544#[stable(feature = "futures_api", since = "1.36.0")]
545pub use core::future;
546#[stable(feature = "core_hint", since = "1.27.0")]
547pub use core::hint;
548#[stable(feature = "rust1", since = "1.0.0")]
549#[allow(deprecated, clippy::legacy_numeric_constants)]
550pub use core::i8;
551#[stable(feature = "rust1", since = "1.0.0")]
552#[allow(deprecated, clippy::legacy_numeric_constants)]
553pub use core::i16;
554#[stable(feature = "rust1", since = "1.0.0")]
555#[allow(deprecated, clippy::legacy_numeric_constants)]
556pub use core::i32;
557#[stable(feature = "rust1", since = "1.0.0")]
558#[allow(deprecated, clippy::legacy_numeric_constants)]
559pub use core::i64;
560#[stable(feature = "i128", since = "1.26.0")]
561#[allow(deprecated, clippy::legacy_numeric_constants)]
562pub use core::i128;
563#[stable(feature = "rust1", since = "1.0.0")]
564pub use core::intrinsics;
565#[stable(feature = "rust1", since = "1.0.0")]
566#[allow(deprecated, clippy::legacy_numeric_constants)]
567pub use core::isize;
568#[stable(feature = "rust1", since = "1.0.0")]
569pub use core::iter;
570#[stable(feature = "rust1", since = "1.0.0")]
571pub use core::marker;
572#[stable(feature = "rust1", since = "1.0.0")]
573pub use core::mem;
574#[stable(feature = "rust1", since = "1.0.0")]
575pub use core::ops;
576#[stable(feature = "rust1", since = "1.0.0")]
577pub use core::option;
578#[stable(feature = "pin", since = "1.33.0")]
579pub use core::pin;
580#[stable(feature = "rust1", since = "1.0.0")]
581pub use core::ptr;
582#[stable(feature = "new_range_api", since = "1.96.0")]
583pub use core::range;
584#[stable(feature = "rust1", since = "1.0.0")]
585pub use core::result;
586#[stable(feature = "rust1", since = "1.0.0")]
587#[allow(deprecated, clippy::legacy_numeric_constants)]
588pub use core::u8;
589#[stable(feature = "rust1", since = "1.0.0")]
590#[allow(deprecated, clippy::legacy_numeric_constants)]
591pub use core::u16;
592#[stable(feature = "rust1", since = "1.0.0")]
593#[allow(deprecated, clippy::legacy_numeric_constants)]
594pub use core::u32;
595#[stable(feature = "rust1", since = "1.0.0")]
596#[allow(deprecated, clippy::legacy_numeric_constants)]
597pub use core::u64;
598#[stable(feature = "i128", since = "1.26.0")]
599#[allow(deprecated, clippy::legacy_numeric_constants)]
600pub use core::u128;
601#[unstable(feature = "unsafe_binders", issue = "130516")]
602pub use core::unsafe_binder;
603#[stable(feature = "rust1", since = "1.0.0")]
604#[allow(deprecated, clippy::legacy_numeric_constants)]
605pub use core::usize;
606
607#[stable(feature = "rust1", since = "1.0.0")]
608pub use alloc_crate::borrow;
609#[stable(feature = "rust1", since = "1.0.0")]
610pub use alloc_crate::boxed;
611#[stable(feature = "rust1", since = "1.0.0")]
612pub use alloc_crate::fmt;
613#[stable(feature = "rust1", since = "1.0.0")]
614pub use alloc_crate::format;
615#[stable(feature = "rust1", since = "1.0.0")]
616pub use alloc_crate::rc;
617#[stable(feature = "rust1", since = "1.0.0")]
618pub use alloc_crate::slice;
619#[stable(feature = "rust1", since = "1.0.0")]
620pub use alloc_crate::str;
621#[stable(feature = "rust1", since = "1.0.0")]
622pub use alloc_crate::string;
623#[stable(feature = "rust1", since = "1.0.0")]
624pub use alloc_crate::vec;
625
626#[path = "num/f128.rs"]
627pub mod f128;
628#[path = "num/f16.rs"]
629pub mod f16;
630#[path = "num/f32.rs"]
631pub mod f32;
632#[path = "num/f64.rs"]
633pub mod f64;
634
635#[macro_use]
636pub mod thread;
637pub mod ascii;
638pub mod backtrace;
639#[unstable(feature = "byte_str", issue = "134915")]
640pub mod byte_str;
641pub mod collections;
642pub mod env;
643pub mod error;
644pub mod ffi;
645pub mod fs;
646pub mod hash;
647pub mod io;
648pub mod net;
649pub mod num;
650#[allow(unreachable_pub)]
651pub mod os;
652pub mod panic;
653#[unstable(feature = "pattern_type_macro", issue = "123646")]
654pub mod pat;
655pub mod path;
656pub mod process;
657#[unstable(feature = "random", issue = "130703")]
658pub mod random;
659pub mod sync;
660pub mod time;
661#[unstable(feature = "view_type_macro", issue = "155938")]
662pub mod view;
663
664// Pull in `std_float` crate  into std. The contents of
665// `std_float` are in a different repository: rust-lang/portable-simd.
666#[path = "../../portable-simd/crates/std_float/src/lib.rs"]
667#[allow(missing_debug_implementations, dead_code, unsafe_op_in_unsafe_fn)]
668#[allow(rustdoc::bare_urls)]
669#[unstable(feature = "portable_simd", issue = "86656")]
670mod std_float;
671
672#[unstable(feature = "portable_simd", issue = "86656")]
673pub mod simd {
674    #![doc = include_str!("../../portable-simd/crates/core_simd/src/core_simd_docs.md")]
675
676    #[doc(inline)]
677    pub use core::simd::*;
678
679    #[doc(inline)]
680    pub use crate::std_float::StdFloat;
681}
682
683#[unstable(feature = "autodiff", issue = "124509")]
684#[doc = include_str!("../../core/src/autodiff.md")]
685pub mod autodiff {
686    /// This macro handles automatic differentiation.
687    pub use core::autodiff::{autodiff_forward, autodiff_reverse};
688}
689
690#[unstable(feature = "gpu_offload", issue = "131513")]
691#[doc = include_str!("../../core/src/offload.md")]
692pub mod offload {
693    pub use core::offload::{offload, offload_kernel};
694}
695
696#[stable(feature = "futures_api", since = "1.36.0")]
697pub mod task {
698    //! Types and Traits for working with asynchronous tasks.
699
700    #[doc(inline)]
701    #[stable(feature = "wake_trait", since = "1.51.0")]
702    pub use alloc::task::*;
703    #[doc(inline)]
704    #[stable(feature = "futures_api", since = "1.36.0")]
705    pub use core::task::*;
706}
707
708#[doc = include_str!("../../stdarch/crates/core_arch/src/core_arch_docs.md")]
709#[stable(feature = "simd_arch", since = "1.27.0")]
710pub mod arch {
711    #[stable(feature = "simd_arch", since = "1.27.0")]
712    // The `no_inline`-attribute is required to make the documentation of all
713    // targets available.
714    // See https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 for
715    // more information.
716    #[doc(no_inline)] // Note (#82861): required for correct documentation
717    pub use core::arch::*;
718
719    #[stable(feature = "simd_aarch64", since = "1.60.0")]
720    pub use std_detect::is_aarch64_feature_detected;
721    #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")]
722    pub use std_detect::is_arm_feature_detected;
723    #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")]
724    pub use std_detect::is_loongarch_feature_detected;
725    #[stable(feature = "riscv_ratified", since = "1.78.0")]
726    pub use std_detect::is_riscv_feature_detected;
727    #[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")]
728    pub use std_detect::is_s390x_feature_detected;
729    #[stable(feature = "simd_x86", since = "1.27.0")]
730    pub use std_detect::is_x86_feature_detected;
731    #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
732    pub use std_detect::{is_mips_feature_detected, is_mips64_feature_detected};
733    #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
734    pub use std_detect::{is_powerpc_feature_detected, is_powerpc64_feature_detected};
735}
736
737// This was stabilized in the crate root so we have to keep it there.
738#[stable(feature = "simd_x86", since = "1.27.0")]
739pub use std_detect::is_x86_feature_detected;
740
741#[allow(unreachable_pub)]
742mod sys;
743
744pub mod alloc;
745
746// Private support modules
747mod panicking;
748
749#[path = "../../backtrace/src/lib.rs"]
750#[allow(implicit_provenance_casts, unsafe_op_in_unsafe_fn)]
751#[allow(clippy::len_zero, clippy::needless_borrow, clippy::filter_map_next)] // FIXME
752mod backtrace_rs;
753
754#[stable(feature = "cfg_select", since = "1.95.0")]
755pub use core::cfg_select;
756#[unstable(
757    feature = "concat_bytes",
758    issue = "87555",
759    reason = "`concat_bytes` is not stable enough for use and is subject to change"
760)]
761pub use core::concat_bytes;
762#[allow(clippy::useless_attribute)]
763#[expect(
764    ineffective_unstable_reexports,
765    reason = "accepted as stable after accidental stabilization in 1.96, see #154645"
766)]
767#[unstable(feature = "derive_macro_global_path", issue = "154645")]
768pub use core::derive;
769#[unstable(feature = "gca_min_const_items", issue = "132980", implied_by = "gca_adts")]
770pub use core::gca;
771#[stable(feature = "matches_macro", since = "1.42.0")]
772pub use core::matches;
773#[stable(feature = "core_primitive", since = "1.43.0")]
774pub use core::primitive;
775#[stable(feature = "todo_macro", since = "1.40.0")]
776pub use core::todo;
777// Re-export built-in macros defined through core.
778#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
779pub use core::{
780    assert, cfg, column, compile_error, concat, const_format_args, env, file, format_args,
781    format_args_nl, include, include_bytes, include_str, line, log_syntax, module_path, option_env,
782    stringify, trace_macros,
783};
784// Re-export macros defined in core.
785#[stable(feature = "rust1", since = "1.0.0")]
786#[expect(deprecated, reason = "`try! macro")]
787pub use core::{
788    assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, r#try, unimplemented,
789    unreachable, write, writeln,
790};
791#[stable(feature = "assert_matches", since = "1.96.0")]
792pub use core::{assert_matches, debug_assert_matches};
793
794// Re-export unstable derive macro defined through core.
795#[unstable(feature = "derive_from", issue = "144889")]
796/// Unstable module containing the unstable `From` derive macro.
797pub mod from {
798    #[unstable(feature = "derive_from", issue = "144889")]
799    pub use core::from::From;
800}
801
802// We include the following files here *again* (they are already included in libcore)
803// so that they show up in search results for the std crate, and to avoid breaking
804// existing links:
805
806// documentation for built-in attributes. Using `include!` because rustdoc
807// only looks for these modules at the crate level.
808include!("../../core/src/attribute_docs.rs");
809
810// Include a number of private modules that exist solely to provide
811// the rustdoc documentation for the existing keywords. Using `include!`
812// because rustdoc only looks for these modules at the crate level.
813include!("../../core/src/keyword_docs.rs");
814
815// Include a number of private modules that exist solely to provide
816// the rustdoc documentation for primitive types. Using `include!`
817// because rustdoc only looks for these modules at the crate level.
818include!("../../core/src/primitive_docs.rs");
819
820// This is required to avoid an unstable error when `restricted-std` is not
821// enabled. The use of #![feature(restricted_std)] in rustc-std-workspace-std
822// is unconditional, so the unstable feature needs to be defined somewhere.
823#[unstable(feature = "restricted_std", issue = "none")]
824mod __restricted_std_workaround {}
825
826#[cfg(test)]
827#[allow(dead_code)] // Not used in all configurations.
828pub(crate) mod test_helpers;