Skip to content

Refactor prefixed path - #175

Open
lforchini wants to merge 1 commit into
test/refactor-config-loadingfrom
refactor/util-path
Open

lforchini wants to merge 1 commit into
test/refactor-config-loadingfrom
refactor/util-path

Conversation

@lforchini

Copy link
Copy Markdown
Collaborator

Rename our custom Path to be PrefixedPath to prevent the collision with
std's Path. Also move it to its own dedicated path module instead of the
generic util.rs. Update all usages to use the new name and module.

The new name, PrefixedPath, should improve clarity when converting to
and from std's Path.

Signed-off-by: Leonardo Forchini leonardo.forchini@nutanix.com


Stack created with GitHub Stacks CLI • Give Feedback 💬

@lforchini
lforchini added this pull request to stack #176 November 5, 2026 15:03
@lforchini
lforchini removed this pull request from stack #176 November 5, 2026 15:09
@lforchini
lforchini added this pull request to stack #178 November 5, 2026 15:10

@tmakatos tmakatos left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the collision problem? I prefer the fact that we don't have to explicitly a different type othen than Path, plus using PrefixedPath feels heavier from a mental point of view (and it's conceptually not much different than explicitly passing the root directory everywhere as an extra argument).

@lforchini

Copy link
Copy Markdown
Collaborator Author

I find that both being Path increases the cognitive load because I keep having to figure out whether it's ours or std's. For now, I've been using our path as just Path and std's as std::path::Path to try and lessen the ambiguity. I think using a different name removes cognitive overhead instead of adding it.

Maybe we can add an extension trait to std Path which can add the prefix to add a new_with_root constructor? I could also change the name to something more subtle like PPath?

@lforchini
lforchini removed this pull request from stack #178 November 6, 2026 10:23
@lforchini
lforchini added this pull request to stack #180 November 6, 2026 10:24
@tmakatos

Copy link
Copy Markdown
Collaborator

Maybe we can add an extension trait to std Path which can add the prefix to add a new_with_root constructor?

If that avoids having to introduce a new name I'd prefer it.

Rename our custom Path to be PrefixedPath to prevent the collision with
std's Path. Also move it to its own dedicated path module instead of the
generic `util.rs`. Update all usages to use the new name and module.

The new name, PrefixedPath, should improve clarity when converting to
and from std's Path.

Signed-off-by: Leonardo Forchini <leonardo.forchini@nutanix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants