我已经开始编写 no_std Rust 代码,现在我正在尝试添加字符串。
这是我的代码:
#![no_std]
extern crate libc;
fn add_string(string: &str) {
const STRING1: &'static str = string;
const STRING2: &'static str = "String2";
const TEXT: &str = STRING1 + STRING2;
unsafe { libc::printf(TEXT.as_ptr() as *const _); }
}
#[no_mangle]
extern "C" fn main() -> ! {
add_string("String1 ");
}
在 no_std 程序中是否有任何好的库可以做这样的事情?