v0.0.0b
This commit is contained in:
18
x/Cargo.toml
Normal file
18
x/Cargo.toml
Normal file
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "x"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
default = ["core"]
|
||||
core = ["sub_core"]
|
||||
libm = ["sub_libm"]
|
||||
pe = ["sub_pe"]
|
||||
|
||||
winuser = ["sub_winu", "pe", "sub_pe/windows"]
|
||||
|
||||
[dependencies]
|
||||
sub_core = { workspace = true, optional = true }
|
||||
sub_libm = { workspace = true, optional = true}
|
||||
sub_pe = { workspace = true, optional = true }
|
||||
sub_winu = { workspace = true, optional = true }
|
||||
21
x/src/lib.rs
Normal file
21
x/src/lib.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
#![no_std] #![feature(decl_macro)] #![allow(unused)]
|
||||
|
||||
|
||||
macro_rules! import {
|
||||
($module:ident, $name:ident) => {
|
||||
pub use $module::prelude::*;
|
||||
pub use $module::public as $name;
|
||||
};
|
||||
($module:ident, $name:ident, $feature:literal) => {
|
||||
#[cfg(feature = $feature)]
|
||||
pub use $module::prelude::*;
|
||||
#[cfg(feature = $feature)]
|
||||
pub use $module::public as $name;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
import!(sub_core, core, "core");
|
||||
import!(sub_libm, libm, "libm");
|
||||
import!(sub_pe, pe, "pe");
|
||||
import!(sub_winu, win, "winuser");
|
||||
21
x/tests/test_core.rs
Normal file
21
x/tests/test_core.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
#[test]
|
||||
pub fn test_once() {
|
||||
let mut i = 0;
|
||||
for _ in 0..3 {
|
||||
if x::once!() { i+= 1; }
|
||||
if x::once!() { i+= 1; }
|
||||
}
|
||||
assert_eq!(i, 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
pub fn test_chain() {
|
||||
let a = 0x1337;
|
||||
let b = [None,None,Some(&a)];
|
||||
let c = [None,Some(&b), None];
|
||||
assert_eq!(0x1337, x::ptr_chain!(&c as *const _, 0x8, 0x10, 0x0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user