Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created May 10, 2021
Embed
What would you like to do?
Code shared from the Rust Playground
fn main() {
println!("Hello, world!");
}
// rustfmt dose not work Self::LuckyCookieMonkeyMondeySunday
// rustfmt dose not work Self::FooBarBazHogeFugaPiyoJapan
impl fmt::Display for Foo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::LuckyCookieMonkeyMondeySunday{position,op_code,address}=>format!("xyz xyz yes yes no no ABCDEFGHIJK abcdefghijk {} (foo bar baz {}) abcdefghijkl ({})",position,op_code,address).fmt(f),
Self::ThisIsAPen { ppap } => format!("{} is Password security?", ppap).fmt(f),
Self::FooBarBazHogeFugaPiyoJapan{position,op_code,address}=>format!("xyz xyz yes yes no no ABCDEFGHIJK abcdefghijk {} (foo bar baz {}) abcdefghijkl ({})",position,op_code,address).fmt(f),
Self::Season(month) => {
format!("This is {}. There are 4 seasons in Japan!", month).fmt(f)
}
}
}
}
impl fmt::Display for FooBar {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::ApplePieX { foo, bar } => format!("Apple {} {}", foo, bar).fmt(f),
Self::AccessPermissionDenied { foo, bar, baz } => {
format!("Cherry {}{}{} !", foo, bar, baz).fmt(f)
}
Self::MonkeyKidsX { age, country } => {
format!("Monkey is {} years old in {}", age, country).fmt(f)
}
Self::JapanesePeopleX { reason } => {
format!("Why? Japanese People? because {}", reason).fmt(f)
}
Self::ComputerScienceX { difficulty } => {
format!("computer science is very {}", difficulty).fmt(f)
}
Self::ThisIsAPenX { ppap } => format!("{} is Password security?", ppap).fmt(f),
Self::SeasonX(month) => {
format!("This is {}. There are 4 seasons in Japan!", month).fmt(f)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment