-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking Issue for io_error_downcast #99262
Copy link
Copy link
Closed
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.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
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.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Feature gate:
#![feature(io_error_downcast)]This is a tracking issue for new API
std::io::Error::downcast.Existing APIs requires two separate calls to obtain the raw os error or the inner error and they both return
Option.Thus, users would have to first call
Error::get_refto check that we indeed has an inner error and checked that itisthe type we expected.Users cannot use
std::io::Error::into_innerbecuase takes the error by value and returnsOption<Box<dyn Error + Send + Sync>>instead ofResult<Box<dyn Error + Send + Sync>, Self>.They also cannot workaround this issue by calling
Error::raw_os_error, since theio::Errorcan also be constructed usingimpl From<ErrorKind> for Erroror using other internal methods only accessible by the std library.This new feature
io_error_downcastsolved this issue by providing new APIstd::io::Error::downcastto downcast the inner error easily withoutunwraporexpect.Public API
Steps / History
try_downcast_innertostd::io::Errorlibs-team#57downcasttostd::io::Error#98387std::io::Error::downcastreturn type and doc: Updatestd::io::Error::downcastreturn type #120117Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩