I'm new to Rust programming and learning about lifetimes.
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);
}
The output:
CONST_MEEP is MEEP
CONST_LIFETIME_MEEP is MEEP
STATIC_MEEP is MEEP
STATIC_LIFETIME_MEEP is MEEP
What is the difference between CONST_MEEP
and CONST_LIFETIME_MEEP
? What is the difference between STATIC_MEEP
and STATIC_LIFETIME_MEEP
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.