Created
October 25, 2021 21:00
-
-
Save Shaun289/484b7f1fdf078f9f5ba1ef21b6296c3f to your computer and use it in GitHub Desktop.
Rust study : Formatted print Debug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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