Skip to content

Commit

Permalink
alloc, core, std, and a quite expansive prelude?
Browse files Browse the repository at this point in the history
  • Loading branch information
meadowsys committed Sep 8, 2024
1 parent 22eae9c commit 928ce7f
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ wiwiwiwiwi = { path = "macro", version = "=0.10.0" }
# zeroize = { version = "1.7.0", optional = true }

[features]
alloc = []
std = []

[build-dependencies]
# cc = "1.1.6"
Expand Down
7 changes: 5 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![no_implicit_prelude]

// TODO: review these
Expand Down Expand Up @@ -26,7 +25,11 @@ compile_error!("16-bit platforms are not supported yet (but please do file an is
#[cfg(any(doc, docsrs, kiwingay))]
#[doc = include_str!("../CHANGELOG.md")]
pub mod _changelog {}
// pub mod prelude;
pub mod prelude;

pub mod rust_alloc;
pub mod rust_core;
pub mod rust_std;

// pub mod clone;
// pub mod compare;
Expand Down
102 changes: 102 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1 +1,103 @@
//! Prelude module, exporting commonly-used items

use crate::rust_std;

pub use rust_std::{
assert,
assert_eq,
assert_ne,
debug_assert,
debug_assert_eq,
debug_assert_ne,
print,
println,
eprint,
eprintln,
cfg,
dbg,
unreachable,
concat,
compile_error,
file,
line,
column,
format,
format_args,
stringify
};
pub use rust_std::borrow::{
Cow,
ToOwned
};
pub use rust_std::convert::{
From,
Into,
TryFrom,
TryInto,
AsMut,
AsRef,
identity
};
pub use rust_std::future::{
Future,
IntoFuture
};
pub use rust_std::iter::{
Iterator,
FromIterator,
IntoIterator,
DoubleEndedIterator,
ExactSizeIterator,
Extend
};
pub use rust_std::marker::{
Send,
Sync,
Sized,
Unpin,
PhantomData,
PhantomPinned
};
pub use rust_std::mem::{
size_of,
size_of_val,
align_of,
align_of_val,
drop,
forget,
replace,
swap,
take,
transmute,
transmute_copy,
zeroed
};
pub use rust_std::ops::{
Drop,
Fn,
FnMut,
FnOnce
};
pub use rust_std::option::{
Option,
Option::Some,
Option::None
};
pub use rust_std::result::{
Result,
Result::Ok,
Result::Err
};
pub use rust_std::string::{
String,
ToString
};
pub use rust_std::vec::Vec;

#[macro_export]
macro_rules! panic {
($($stuff:tt)*) => {
$crate::rust_std::panic!($($stuff)*)
}
}
pub use panic;
4 changes: 4 additions & 0 deletions src/rust_alloc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extern crate alloc as _alloc;

#[doc(inline)]
pub use _alloc::*;
4 changes: 4 additions & 0 deletions src/rust_core.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extern crate core as _core;

#[doc(inline)]
pub use _core::*;
4 changes: 4 additions & 0 deletions src/rust_std.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extern crate std as _std;

#[doc(inline)]
pub use _std::*;

0 comments on commit 928ce7f

Please sign in to comment.