// main.rs
#[derive(Debug)]
struct Animal<'a>{
name:&'a str,
age:i32
}
static my_dog: Animal=Animal{
name:"bzzb",
age:2
};
fn main(){
println!("{:?}",my_dog);
}
that is profile in cargo book Profiles - The Cargo Book
// when cargo build, and i print the static variable in gdb it has been initialized
(gdb) p learn::my_dog
$1 = learn::Animal {name: "bzzb", age: 2}
// but when cargo build with profile provided by cargo document, it seems that my_dog has not been initialized
(gdb) p learn::my_dog
$1 = learn::Animal {name: "", age: 0}
// until i excute run command the variable be initialized
(gdb) b main
Breakpoint 1 at 0x7b50
(gdb) r
Starting program: /home/oslab/repos/learn-rust/target/debug/learn
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, 0x000055555555bb50 in main ()
(gdb) p learn::my_dog
$2 = learn::Animal {name: "bzzb", age: 2}