Think I just ran into a wart in Rust. Luckily I've got the time and enough experience at this point to know I'll be able to solve this, but others might not. Basically it's this: let foo = match bar { Some(bar) => bar, None => &make_bar()?, } where `bar` is borrowed.
Aw, struggling with implementing Cow properly for my own structs here. Not a simple fix either :(
-
-
You want to impl the API Cow gives you or use a Cow in your struct? You might also want to look at https://docs.rs/supercow if you need even more bovine power
-
Heh, well - the idea was to wrap my struct in a Cow so I can use it to return an owned version from the match statement. But that requires implementing a special `From` impl that feels a bit confusing. At this point I feel like a closure might be the least confusing option.
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.