feat(wpcarro/rust): Include std::fmt::Display example

Gotta know how to `to_string` things

Change-Id: I259ef61ecaf6ae7fabe0b3d211706ba5f429b3a7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6057
Reviewed-by: wpcarro <wpcarro@gmail.com>
Autosubmit: wpcarro <wpcarro@gmail.com>
Tested-by: BuildkiteCI
This commit is contained in:
William Carroll 2022-08-09 10:20:03 -07:00 committed by clbot
parent 783e1190cd
commit 4732603a42
6 changed files with 123 additions and 50 deletions

View file

@ -0,0 +1,13 @@
use std::fmt;
pub struct Person {
pub fname: String,
pub lname: String,
pub age: i8,
}
impl fmt::Display for Person {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}, {} ({} years old)", self.lname, self.fname, self.age)
}
}