-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
It is a pain to go from Option<String>
to Option<&str>
:
opt.as_ref().map(|s| s.as_slice())
This could be improved by integrating the new BorrowFrom
infrastructure, generalizing the signature of as_ref
from
fn as_ref(&self) -> Option<&T>
to
fn as_ref<U=T>(&self) -> Option<&U> where U: BorrowFrom<T>
However, to avoid a regression in type inference for types that can be borrowed in multiple ways, we need default type parameters on methods (as above). See rust-lang/rfcs#213
schneiderfelipe
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.