refactor: migrate to more permissive/accurate String parameter types#161
Open
jschillem wants to merge 2 commits intorust-netlink:mainfrom
Open
refactor: migrate to more permissive/accurate String parameter types#161jschillem wants to merge 2 commits intorust-netlink:mainfrom
String parameter types#161jschillem wants to merge 2 commits intorust-netlink:mainfrom
Conversation
The API exclusively accepted `String` parameters before. This is forcing an unergonmic API for users by forcing them to allocate a `String` for an internal detail.
There was a problem hiding this comment.
Code Review
This pull request refactors various functions and API methods to use more idiomatic Rust types for string and path arguments, specifically replacing String with impl Into<String> and impl AsRef<Path>. This improves ergonomics by allowing callers to pass string literals or references without explicit conversions. However, several issues were identified in the src/ns.rs file, including a compilation error due to the use of non-existent methods on PathBuf and Path, as well as redundant path manipulation logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The API exclusively accepted
Stringparameters before. This is forcing an unergonomic API for users by forcing them to allocate aStringfor an internal detail.This PR changes all APIs that previously accept
Stringinto genericimpl Into<String>orimpl AsRef<Path>. These changes are backwards compatible asStringimplements both of these trait bounds.The only breaking change is converting the return type of
child_process_create_nsinns.rstoResult<PathBuf, Error>. This is more accurate to what should be returned as it is returning a file path. However, I am also wondering why this function is exposed as public while its wrapping functionchild_processis not.