rust/library/core/src/primitive.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.1 KiB
Rust
Raw Normal View History

//! This module reexports the primitive types to allow usage that is not
//! possibly shadowed by other declared types.
//!
//! This is normally only useful in macro generated code.
//!
//! An example of this is when generating a new struct and an impl for it:
//!
//! ```rust,compile_fail
//! pub struct bool;
//!
//! impl QueryId for bool {
//! const SOME_PROPERTY: bool = true;
//! }
//!
//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; }
//! ```
//!
//! Note that the `SOME_PROPERTY` associated constant would not compile, as its
//! type `bool` refers to the struct, rather than to the primitive bool type.
//!
//! A correct implementation could look like:
//!
//! ```rust
//! # #[allow(non_camel_case_types)]
//! pub struct bool;
//!
//! impl QueryId for bool {
//! const SOME_PROPERTY: core::primitive::bool = true;
//! }
//!
//! # trait QueryId { const SOME_PROPERTY: core::primitive::bool; }
//! ```
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use bool;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use char;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use f32;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use f64;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use i128;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use i16;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use i32;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use i64;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use i8;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use isize;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use str;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use u128;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use u16;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use u32;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use u64;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use u8;
2020-02-24 01:59:39 -06:00
#[stable(feature = "core_primitive", since = "1.43.0")]
pub use usize;