Skip to content

Instantly share code, notes, and snippets.

@Shaun289
Created October 25, 2021 21:00
Show Gist options
  • Save Shaun289/484b7f1fdf078f9f5ba1ef21b6296c3f to your computer and use it in GitHub Desktop.
Save Shaun289/484b7f1fdf078f9f5ba1ef21b6296c3f to your computer and use it in GitHub Desktop.
Rust study : Formatted print Debug
/*
The rust by example ko https://hanbum.gitbooks.io/rustbyexample/content/hello/print/print_debug.html
compiled on https://play.rust-lang.org/
result:
12 months in a year
"Christian" "Slater" is the "actor's" name.
Now Structure(3) will print!
Now Deep(Structure(3)) will print!
*/
#[derive(Debug)]
struct Structure(
i32
);
#[derive(Debug)]
struct Deep(
Structure
);
fn main()
{
println!("{:?} months in a year", 12);
println!("{1:?} {0:?} is the {actor:?} name.",
"Slater",
"Christian",
actor="actor's"
);
println!("Now {:?} will print!", Structure(3));
println!("Now {:?} will print!", Deep(Structure(3)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment