标准IO输出
1. 使用 println! 宏
println! 宏fn main() {
println!("Hello, World!");
}2. 格式化输出
let name = "Alice";
let age = 30;
println!("{} is {} years old.", name, age);3. 使用 print! 宏
print! 宏print!("This will be printed on the same line.");4. 使用 std::io::stdout
std::io::stdoutuse std::io::{self, Write};
fn main() {
let mut stdout = io::stdout();
stdout.write_all(b"Hello, World!\n").unwrap();
}5. 缓冲输出
6. 总结
Last updated