1
0
Fork 0
forked from AbleOS/ableos
ableos-idl/ableos/src/utils.rs

37 lines
624 B
Rust
Raw Normal View History

//! Small generic utilities
2022-04-11 17:23:11 -05:00
2022-02-22 18:15:16 -06:00
#[inline]
pub fn type_of<T>(_: &T) -> &str {
core::any::type_name::<T>()
}
2022-04-11 17:23:11 -05:00
#[no_mangle]
#[allow(unconditional_recursion)]
pub extern "C" fn stack_overflow() -> u8 {
stack_overflow();
// meme number
69 // NOTE: Any specific reason for this number aside from memes?
}
#[cfg(test)]
mod tests {
use super::*;
// #[test]
fn test_type_of() {
assert_eq!(type_of(&1), "i32");
}
}
2022-05-12 21:07:06 -05:00
pub const fn kb(x: usize) -> usize {
x * 1024
}
pub const fn mb(x: usize) -> usize {
x * 1024 * 1024
}
pub const fn gb(x: usize) -> usize {
x * 1024 * 1024 * 1024
}