-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.
Description
Feature gate: #![feature(error_generic_member_access)]
This is a tracking issue for the generic member access API on the error trait, which generalizes the pattern of fn source(&self) -> Option<&dyn Error> and fn backtrace(&self) -> Option<&Backtrace> into fn request_ref::<T>(&self) -> Option<&T>
Public API
// std::error
pub trait Error: Debug + Display {
// existing API unchanged
fn provide<'a>(&'a self, req: &mut Request<'a>) {}
}
pub struct Request<'a> { .. }
impl<'a> Request<'a> {
pub fn provide_value<T>(&mut self, value: T) -> &mut Request<'a>
where
T: 'static;
pub fn provide_value_with<T>(
&mut self,
fulfil: impl FnOnce() -> T,
) -> &mut Request<'a>
where
T: 'static;
pub fn provide_ref<T>(&mut self, value: &'a T) -> &mut Request<'a>
where
T: 'static + ?Sized;
pub fn provide_ref_with<T>(
&mut self,
fulfil: impl FnOnce() -> &'a T,
) -> &mut Request<'a>
where
T: 'static + ?Sized;
pub fn would_be_satisfied_by_value_of<T>(&self) -> bool
where
T: 'static;
pub fn would_be_satisfied_by_ref_of<T>(&self) -> bool
where
T: 'static + ?Sized;
}
pub fn request_ref<'a, T: ?Sized + 'static>(err: &'a (impl Error + ?Sized)) -> Option<&'a T>;
pub fn request_value<T: 'static>(err: &(impl Error + ?Sized)) -> Option<T>;Steps / History
Now tracked by @waynr in #99301 (comment)
- recent zulip discussion: #t-libs > Pushing error_generic_member_access forward
Unresolved Questions
- None yet.
stepancheg, tgross35, thebluetropics, jess-sol, schneiderfelipe and 15 morerobsdedude, adriandelgado, artob, chamons and joseluis
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.In the final comment period and will be merged soon unless new substantive objections are raised.