I would like to nominate `Option::as_deref` for the worst named method in Rust
It'd return `None`. This would require GATs so that it was `fn deref(&self) -> Self::Target<'_>`, letting you return an option of a reference for example.
-
-
oh I'd not thought of it like that: of course Option<T> could impl Deref with Target = Option<<T as Deref>::Target>, which wouldn't make Option<T> transparently equal to T under Deref, but I'd not considered the lifetime problem that requires GAT
-
Ironically you can almost implement this for `Option`, since null ptr optimization means that `&T == &Option<T>` in terms of layout. Except it's not particularly useful since that'd require `T: Sized`, meaning `Option<String>` couldn't impl `Deref`
- 3 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.