Created
November 17, 2020 04:09
-
-
Save richo/1f9ea71ec76146bb9f8e31e7ca20dd32 to your computer and use it in GitHub Desktop.
This file contains 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
pub enum Thing { | |
Lol { | |
name: String, | |
other: u64, | |
}, | |
Haha { | |
name: String, | |
whatever: i8, | |
} | |
} | |
impl Thing { | |
fn with_modification(&self) -> Thing { | |
use Thing::*; | |
let tweak = "hahahahaha"; | |
match self { | |
lol @ Lol { .. } => { | |
let new = lol.clone(); | |
new.name.push_str(tweak); | |
new | |
}, | |
haha @ Haha { .. } => { | |
let new = haha.clone(); | |
new.name.push_str(tweak); | |
new | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment