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

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

Brenner pfp
Brenner
@brenner.eth
The allocation of a small string i don’t think is a big problem here What’s wrong with using the function you linked to?
1 reply
0 recast
0 reaction

Parsa pfp
Parsa
@parsa
The allocation is definitely fine, I'm just weird, lol. and the code I shared actually does what it is meant to do; it's just a little ugly to wrap things in a `W` all the time. That's my only issue with it. But honestly, I wish `Option<T> || Option<T>` was a thing supported by default.
1 reply
0 recast
1 reaction