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

Change path to mimic std::path #1061

Merged
merged 3 commits into from
Oct 24, 2023
Merged

Conversation

tsoutsman
Copy link
Member

@tsoutsman tsoutsman commented Oct 21, 2023

This PR changes path to export a Path and PathBuf struct, akin to std::path. Initially I made this change because it was necessary for Rust FFI for the std port, but it turns out the change also removed a lot of unnecessary allocations throughout the codebase.

  • Change Path::file_stem() to return an Option<&str>
    • This causes crate_name_from_path() to return a Result

This PR changes `path` to export a `Path` and `PathBuf` struct, akin to
`std::path`. Initially I made this change because it was necessary for
Rust FFI for the `std` port, but it turns out the change also removed a
lot of unnecessary allocations throughout the codebase.

Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
Copy link
Member

@kevinaboos kevinaboos left a comment

Choose a reason for hiding this comment

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

Thanks a lot! Looks good.

I left a few very minor comments. Code-wise everything is fine.

kernel/path/src/lib.rs Outdated Show resolved Hide resolved
kernel/path/Cargo.toml Outdated Show resolved Hide resolved
kernel/path/src/lib.rs Outdated Show resolved Hide resolved
Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
@kevinaboos kevinaboos merged commit 3fd2e4c into theseus-os:theseus_main Oct 24, 2023
3 checks passed
github-actions bot pushed a commit that referenced this pull request Oct 24, 2023
* The `path` crate now exports a `Path` and `PathBuf` struct,
  akin to `std::path`. This makes it easier to support `std`,
  but also removes unnecessary allocations throughout Theseus.

* Notably, `Path::file_stem()` now returns an `Option<&str>`.
  * This causes `crate_name_from_path()` to return a `Result`,
    which is responsible for most of the logic changes required.

Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com> 3fd2e4c
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