Skip to main content

std/prelude/
v1.rs

1//! The first version of the prelude of The Rust Standard Library.
2//!
3//! See the [module-level documentation](super) for more.
4
5#![stable(feature = "rust1", since = "1.0.0")]
6
7// No formatting: this file is nothing but re-exports, and their order is worth preserving.
8#![cfg_attr(rustfmt, rustfmt::skip)]
9
10// Re-exported core operators
11#[stable(feature = "rust1", since = "1.0.0")]
12#[doc(no_inline)]
13pub use crate::marker::{Send, Sized, Sync, Unpin};
14#[stable(feature = "rust1", since = "1.0.0")]
15#[doc(no_inline)]
16pub use crate::ops::{Drop, Fn, FnMut, FnOnce};
17#[stable(feature = "async_closure", since = "1.85.0")]
18#[doc(no_inline)]
19pub use crate::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
20
21// Re-exported functions
22#[stable(feature = "rust1", since = "1.0.0")]
23#[doc(no_inline)]
24pub use crate::mem::drop;
25#[stable(feature = "size_of_prelude", since = "1.80.0")]
26#[doc(no_inline)]
27pub use crate::mem::{align_of, align_of_val, size_of, size_of_val};
28
29// Re-exported types and traits
30#[stable(feature = "rust1", since = "1.0.0")]
31#[doc(no_inline)]
32pub use crate::convert::{AsMut, AsRef, From, Into};
33#[stable(feature = "rust1", since = "1.0.0")]
34#[doc(no_inline)]
35pub use crate::iter::{DoubleEndedIterator, ExactSizeIterator};
36#[stable(feature = "rust1", since = "1.0.0")]
37#[doc(no_inline)]
38pub use crate::iter::{Extend, IntoIterator, Iterator};
39#[stable(feature = "rust1", since = "1.0.0")]
40#[doc(no_inline)]
41pub use crate::option::Option::{self, None, Some};
42#[stable(feature = "rust1", since = "1.0.0")]
43#[doc(no_inline)]
44pub use crate::result::Result::{self, Err, Ok};
45
46// Re-exported built-in macros and traits
47#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
48#[doc(no_inline)]
49#[expect(deprecated)]
50pub use core::prelude::v1::{
51    assert, assert_eq, assert_ne, cfg, column, compile_error, concat, debug_assert, debug_assert_eq,
52    debug_assert_ne, env, file, format_args, include, include_bytes, include_str, line, matches,
53    module_path, option_env, stringify, todo, r#try, unimplemented, unreachable, write,
54    writeln, Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd,
55};
56
57#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
58#[doc(no_inline)]
59pub use crate::{
60    dbg, eprint, eprintln, format, is_x86_feature_detected, print, println, thread_local
61};
62
63// These macros need special handling, so that we don't export them *and* the modules of the same
64// name. We only want the macros in the prelude so we shadow the original modules with private
65// modules with the same names.
66mod ambiguous_macros_only {
67    #[expect(hidden_glob_reexports)]
68    mod vec {}
69    #[expect(hidden_glob_reexports)]
70    mod panic {}
71    // Building std without the expect exported_private_dependencies will create warnings, but then
72    // clippy claims its a useless_attribute. So silence both.
73    #[expect(clippy::useless_attribute)]
74    #[expect(exported_private_dependencies)]
75    #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
76    pub use crate::*;
77}
78#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
79#[doc(no_inline)]
80pub use self::ambiguous_macros_only::{vec, panic};
81
82#[stable(feature = "cfg_select", since = "1.95.0")]
83#[doc(no_inline)]
84pub use core::prelude::v1::cfg_select;
85
86#[unstable(
87    feature = "concat_bytes",
88    issue = "87555",
89    reason = "`concat_bytes` is not stable enough for use and is subject to change"
90)]
91#[doc(no_inline)]
92pub use core::prelude::v1::concat_bytes;
93
94#[unstable(feature = "const_format_args", issue = "none")]
95#[doc(no_inline)]
96pub use core::prelude::v1::const_format_args;
97
98#[unstable(
99    feature = "log_syntax",
100    issue = "29598",
101    reason = "`log_syntax!` is not stable enough for use and is subject to change"
102)]
103#[doc(no_inline)]
104pub use core::prelude::v1::log_syntax;
105
106#[unstable(
107    feature = "trace_macros",
108    issue = "29598",
109    reason = "`trace_macros` is not stable enough for use and is subject to change"
110)]
111#[doc(no_inline)]
112pub use core::prelude::v1::trace_macros;
113
114// Do not `doc(no_inline)` so that they become doc items on their own
115// (no public module for them to be re-exported from).
116#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
117pub use core::prelude::v1::{
118    alloc_error_handler, bench, global_allocator, test, test_case,
119};
120
121#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
122#[doc(no_inline)]
123pub use core::prelude::v1::derive;
124
125#[unstable(feature = "derive_const", issue = "118304")]
126pub use core::prelude::v1::derive_const;
127
128// Do not `doc(no_inline)` either.
129#[unstable(
130    feature = "cfg_accessible",
131    issue = "64797",
132    reason = "`cfg_accessible` is not fully implemented"
133)]
134pub use core::prelude::v1::cfg_accessible;
135
136// Do not `doc(no_inline)` either.
137#[unstable(
138    feature = "cfg_eval",
139    issue = "82679",
140    reason = "`cfg_eval` is a recently implemented feature"
141)]
142pub use core::prelude::v1::cfg_eval;
143
144// Do not `doc(no_inline)` either.
145#[unstable(
146    feature = "type_ascription",
147    issue = "23416",
148    reason = "placeholder syntax for type ascription"
149)]
150pub use core::prelude::v1::type_ascribe;
151
152// Do not `doc(no_inline)` either.
153#[unstable(
154    feature = "deref_patterns",
155    issue = "87121",
156    reason = "placeholder syntax for deref patterns"
157)]
158pub use core::prelude::v1::deref;
159
160// Do not `doc(no_inline)` either.
161#[unstable(
162    feature = "type_alias_impl_trait",
163    issue = "63063",
164    reason = "`type_alias_impl_trait` has open design concerns"
165)]
166pub use core::prelude::v1::define_opaque;
167
168#[unstable(feature = "extern_item_impls", issue = "125418")]
169pub use core::prelude::v1::{eii, unsafe_eii};
170
171#[unstable(feature = "eii_internals", issue = "none")]
172pub use core::prelude::v1::eii_declaration;
173
174// The file so far is equivalent to core/src/prelude/v1.rs. It is duplicated
175// rather than glob imported because we want docs to show these re-exports as
176// pointing to within `std`.
177// Below are the items from the alloc crate.
178
179#[stable(feature = "rust1", since = "1.0.0")]
180#[doc(no_inline)]
181pub use crate::borrow::ToOwned;
182#[stable(feature = "rust1", since = "1.0.0")]
183#[doc(no_inline)]
184pub use crate::boxed::Box;
185#[stable(feature = "rust1", since = "1.0.0")]
186#[doc(no_inline)]
187pub use crate::string::{String, ToString};
188#[stable(feature = "rust1", since = "1.0.0")]
189#[doc(no_inline)]
190pub use crate::vec::Vec;