Content pfp
Content
@
0 reply
0 recast
0 reaction

Brenner pfp
Brenner
@brenner.eth
this is a vent post in typescript: entrypoint: this.entrypoint || "/bin/sh", in rust: entrypoint: self.entrypoint.clone().unwrap_or("/bin/sh".to_string()),
3 replies
0 recast
5 reactions

Will pfp
Will
@wg
I like Option.as_deref for cases like this: self.entrypoint.as_deref().unwrap_or("/bin/sh").to_owned()
1 reply
0 recast
2 reactions

Parsa pfp
Parsa
@parsa
don't try this at home lol https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=77cf85062519a3b9827ed0a560aac6c4 (clippy: it's better to use `unwrap_or_else(|| "/bin/sh".to_string())` here to avoid allocating a string object if it's not needed.)
1 reply
0 recast
2 reactions

Agost Biro pfp
Agost Biro
@agostbiro
You can always write a macro if something like this gets annoying
0 reply
0 recast
2 reactions