Neat, okay - filed my first papercut: "Borrowing from a match statement isn't possible". Hope it's useful! https://github.com/yoshuawuyts/papercuts/blob/master/2018-05-16-rust.md …
Ahhh, yeah I see where you're going. But believe there's a mistake there. The type returned by the closure will end up being: Result<Result<K, E>, E> Which is incompatible with the return type from `self.cache.get()`. So we'd still need to do `self.db.get(key).unwrap()` :(
-
-
No, the closure's Result *is* the return value of x.ok_or_else if x is None, it doesn't get wrapped
-
This is what I meant: you're getting two different return types by doing it this way. Which means calling `.unwrap()` might cause a panic. Repro https://github.com/yoshuawuyts/repro-or-else … Included screens for output both with type annotations and compiled. Note the different type sigs in 2.pic.twitter.com/FsQS9a9Oer
- 2 more replies
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.