feat: Hook DirsAndFileName push_part_as_dir to FilePath
@@ -81,6 +81,11 @@ impl FilePath {
self.inner = mem::take(&mut self.inner).push_path(path)
}
+ /// Add a `PathPart` to the end of the path's directories.
+ pub fn push_part_as_dir(&mut self, part: &PathPart) {
+ self.inner = mem::take(&mut self.inner).push_part_as_dir(part);
+ }
+
/// Whether the prefix is the start of this path or not.
pub fn prefix_matches(&self, prefix: &Self) -> bool {
self.inner.prefix_matches(&prefix.inner)
@@ -222,6 +227,15 @@ impl FilePathRepresentation {
Self::Parsed(dirs_and_file_name)
}
+ /// Add a `PathPart` to the end of the path's directories.
+ fn push_part_as_dir(self, part: &PathPart) -> Self {
+ let mut dirs_and_file_name: DirsAndFileName = self.into();
+
+ dirs_and_file_name.push_part_as_dir(part);
+
+ Self::Parsed(dirs_and_file_name)
+ }
+
fn prefix_matches(&self, prefix: &Self) -> bool {
use FilePathRepresentation::*;
match (self, prefix) {
