Initial commit
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "demo"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,26 @@
|
||||
// Procedural macro
|
||||
// Derive macro
|
||||
|
||||
// #[derive(Debug)]
|
||||
struct User {
|
||||
first_name: String,
|
||||
last_name: String,
|
||||
email: String,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for User {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{} {}", self.first_name, self.last_name)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let tim = User {
|
||||
first_name: "Tim".into(),
|
||||
last_name: "Huizinga".into(),
|
||||
email: "tim@huizinga.dev".into(),
|
||||
};
|
||||
|
||||
println!("User: {tim}");
|
||||
// println!("User: {tim:?}");
|
||||
}
|
||||
Reference in New Issue
Block a user