格式化输出
占位符
{}
:实现std::fmt::Display
特征,用于展示给用户{:?}
:实现std::fmt::Debug
特征,用于调试{:#?}
:类似{:?}
,格式化(多行)
输出函数的返回值
fn get_person() -> String {
String::from("Bob")
}
fn main() {
let person = get_person();
println!("Hello, {person}!");
}
Search