pub struct Dtry<T>(/* private fields */);Expand description
A directory.
A Dtry<T> consists of a mapping from NameSegments to directory
entries, where a directory entry is either a “File” (DtryEntry::File),
that is an element of T, or a “subdirectory” (DtryEntry::SubDir),
which is just another directory.
The terminology is slightly different from the directories paper;
in the directories paper we call DtryEntry a directory, and Dtry is
just the internal node case of DtryEntry (internal node as opposed to
leaf node). This makes Dtry no longer a monad (there isn’t a unit),
but it’s slightly more convenient for our use case here (keeping track
of specializations).
Implementations§
Source§impl<T> Dtry<T>
impl<T> Dtry<T>
Sourcepub fn map<S>(&self, f: &impl Fn(&T) -> S) -> Dtry<S>
pub fn map<S>(&self, f: &impl Fn(&T) -> S) -> Dtry<S>
Produce a new directory given by mapping f over all of the
DtryEntry::File nodes.
Sourcepub fn entries(
&self,
) -> impl Iterator<Item = (&NameSegment, &(LabelSegment, DtryEntry<T>))>
pub fn entries( &self, ) -> impl Iterator<Item = (&NameSegment, &(LabelSegment, DtryEntry<T>))>
Iterate through the entries of the directory.
Sourcepub fn entry(&self, field: &NameSegment) -> Option<&DtryEntry<T>>
pub fn entry(&self, field: &NameSegment) -> Option<&DtryEntry<T>>
Get the entry for field if it exists.
Sourcepub fn singleton(path: &[(NameSegment, LabelSegment)], val: T) -> Self
pub fn singleton(path: &[(NameSegment, LabelSegment)], val: T) -> Self
Create a singleton directory with just one entry at the given path.
Source§impl<T: Clone> Dtry<T>
impl<T: Clone> Dtry<T>
Sourcepub fn flatten(&self) -> Vec<(QualifiedName, QualifiedLabel, T)>
pub fn flatten(&self) -> Vec<(QualifiedName, QualifiedLabel, T)>
Produce the list of paths in self that refer to files, along with the
value of the files that they refer to.
Trait Implementations§
Source§impl<T> From<IndexMap<NameSegment, (LabelSegment, DtryEntry<T>)>> for Dtry<T>
impl<T> From<IndexMap<NameSegment, (LabelSegment, DtryEntry<T>)>> for Dtry<T>
Source§fn from(value: IndexMap<NameSegment, (LabelSegment, DtryEntry<T>)>) -> Self
fn from(value: IndexMap<NameSegment, (LabelSegment, DtryEntry<T>)>) -> Self
Auto Trait Implementations§
impl<T> Freeze for Dtry<T>
impl<T> RefUnwindSafe for Dtry<T>where
T: RefUnwindSafe,
impl<T> Send for Dtry<T>where
T: Send,
impl<T> Sync for Dtry<T>where
T: Sync,
impl<T> Unpin for Dtry<T>where
T: Unpin,
impl<T> UnwindSafe for Dtry<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.