我是Rust编程的新手并且了解有关生命的时间。
const CONST_MEEP: &str = "MEEP";
const CONST_LIFETIME_MEEP: &'static str = "MEEP";
static STATIC_MEEP: &'static str = "MEEP";
static STATIC_LIFETIME_MEEP: &str = "MEEP";
fn main() {
println!("CONST_MEEP is {}", CONST_MEEP);
println!("CONST_LIFETIME_MEEP is {}", CONST_LIFETIME_MEEP);
println!("STATIC_MEEP is {}", STATIC_MEEP);
println!("STATIC_LIFETIME_MEEP is {}", STATIC_LIFETIME_MEEP);
}
输出:
CONST_MEEP is MEEP
CONST_LIFETIME_MEEP is MEEP
STATIC_MEEP is MEEP
STATIC_LIFETIME_MEEP is MEEP
CONST_MEEP
和CONST_LIFETIME_MEEP
之间有什么区别? STATIC_MEEP
和STATIC_LIFETIME_MEEP
之间有什么区别?