Files
Core/src/modules/system.rs
T
Sweetbread 59d825577a feat: Buttons + events
wip: malloc

feat: Buttons
2024-01-31 16:31:47 +03:00

34 lines
667 B
Rust

use crate::sys;
use alloc::string::String;
use cstr_core::CStr;
trait Debuggable {
fn data_iter(self) -> impl Iterator<Item = u8>;
}
impl Debuggable for &str {
fn data_iter(self) -> impl Iterator<Item = u8> {
self.bytes()
}
}
impl Debuggable for &String {
fn data_iter(self) -> impl Iterator<Item = u8> {
self.as_bytes().iter().copied()
}
}
impl Debuggable for &CStr {
fn data_iter(self) -> impl Iterator<Item = u8> {
self.to_bytes().iter().copied()
}
}
pub fn debug_write<Str: Debuggable>(text: Str) {
for byte in text.data_iter() {
unsafe {
sys::_debug_write(byte);
}
}
}