It's interesting to see people complain about potential implicit end of function ergonomics features in @rustlang, ignoring that a lot of the modern language practice is based on similar things, e.g.:
* Deref
* ? with implicit From conversion
* Reborrow
* match ergonomics
-
Show this thread
-
Pascal Retweeted Pascal
I would love to be able to look at the rust code of 2020 in a parallel universe where stuff like https://twitter.com/killercup/status/1001847540072026119 … was a thing
Pascal added,
2 replies 0 retweets 5 likes -
Ommitting the ? operator wouldnt work well with failure's `.context()` method, or `.unwrap()`. Maybe `.foo^?` might be more clear? Separate the casting from how the error handling.
1 reply 0 retweets 0 likes -
The context is always "tried to convert x to y". We could totally automate this in debug mode
1 reply 0 retweets 0 likes -
I always think of the context method to provide a typed history of sorts for errors you encounter. Helps clarify the origin of the error It's close, but think it's slightly different from what you meant. https://paper.dropbox.com/doc/How-To-Failure-Vb2j93CuQKwLR57xX5dUF … has some more on it.
1 reply 0 retweets 0 likes -
Replying to @yoshuawuyts @killercup and
(hope my words make sense here, haha)
1 reply 0 retweets 0 likes -
Not sure I really get it but it's my fault, I'm also working on other stuff right now
failure's Fail::context allows you to supply context to your result -- but `.try_into()?` can already give you a pretty specific error. Can you give an example where you'd need more context?1 reply 0 retweets 1 like -
Oh, so try_into() will be of type `TryIntoError` or something. It'd be nice if in our "foo" module we could turn that into `foo::Error::TryInto` or `foo::Error::BarFn::ConversionError`. The only good way to achieve this would be to wrap errors using (something like) .context().
1 reply 0 retweets 0 likes
The big big benefit of that is that it becomes super obvious which branch produced an error. And using `.causes()` you could trace back all contexts, creating a clear picture of why things failed. Been reading up on Failure, and really like the way it wraps errors in types :D
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.