Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VfsPath: Add 'is_root()` method #44

Merged

Conversation

Property404
Copy link
Contributor

This new method allows checking if a path is root without cloning or constructing anything.

Currently, I believe you have to do either:

  • path.as_str().is_empty() which is less semantically obvious and exposes the implementation
  • path == path.root() which is a bit more expensive because cloning an Arc requires atomic operations.

Previously, you could also do:

  • path.parent().is_none() which had similar issues to path == path.root()

This new method allows checking if a path is root without cloning
or constructing anything.

Currently, I believe you have to do either:
* `path.as_str().is_empty()` which is less semantically obvious and
  exposes the implementation
* `path == path.root()` which is a bit more expensive because cloning an
  `Arc` requires atomic operations.

Previously, you could also do:
* `path.parent().is_none()` which had similar issues to `path ==
path.root()`
@manuel-woelker manuel-woelker merged commit 04361b4 into manuel-woelker:master Dec 6, 2022
@Property404 Property404 deleted the Property404/is-root branch December 18, 2022 18:03
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.

None yet

2 participants