Skip to content

Commit

Permalink
Create an internal prelude
Browse files Browse the repository at this point in the history
When building with `rustc-dep-of-std`, we don't get the core types
imported by default (`Clone`, `Copy`, `Option`). In order to avoid
needing to import these individually, introduce a prelude that includes
them.

This also includes the C numeric types that are frequently used.
  • Loading branch information
tgross35 committed Nov 27, 2024
1 parent 57dfd5b commit b8356e9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ cfg_if! {
use core::iter;
#[allow(unused_imports)]
use core::ops;
#[allow(unused_imports)]
use core::option;
}
}

Expand All @@ -62,6 +60,17 @@ use core::num;
#[allow(unused_imports)]
use core::option::Option;

/// Frequently-used types that are available on all platforms
///
/// We need to reexport the core types so this works with `rust-dep-of-std`.
mod prelude {
#[allow(unused_imports)]
pub(crate) use crate::{
c_char, c_int, c_long, c_longlong, c_short, c_uchar, c_uint, c_ulong, c_ulonglong,
c_ushort, c_void, intptr_t, size_t, ssize_t, Clone, Copy, Option,
};
}

cfg_if! {
if #[cfg(windows)] {
mod fixed_width_ints;
Expand Down

0 comments on commit b8356e9

Please sign in to comment.