Default arguments in Rust
Very quick question; how to do
def spam_and(input='egg'):
return input
in Rust?
Answer:
fn spam_and(input: Option<&str>) -> &str:
if let Some(x) = input {
x
} else {
'egg'
}
}
I don’t see where this can lead, maybe it’s not even correct as a “pattern”.