-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking Issue for implementing DoubleEndedIterator for Ancestors #153070
Copy link
Copy link
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 RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.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.
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 RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Feature gate:
#![feature(reverse_ancestor)]This is a tracking issue for rust-lang/libs-team#745.
It implements the
DoubleEndedIteratortrait on the Ancestor instd::path, so that it's possible to traverse a path both in the back direction throughpath.ancestors()and in the forward direction throughpath.ancestors().rev(). Currently, the latter is not supported becauseAncestorsdoesn't have aDoubleEndedIteratortrait implemented.Public API Example
With this ACP you can do something like:
Iterating through
path.ancestors()would give:And iterating through
path.ancestors().rev()would give:The benefit of this is that you don't need to do something like
path.ancestors().collect()/path.ancestors().take(#).collect()to collect the ancestor paths into aVec<Path>and be able to traverse the path in reverse direction (avoiding an allocation essentially).Steps / History
(Remember to update the
S-tracking-*label when checking boxes.)std::pathlibs-team#745Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩