Skip to content

refactor: migrate to more permissive/accurate String parameter types#161

Open
jschillem wants to merge 2 commits intorust-netlink:mainfrom
jschillem:improve-string-params
Open

refactor: migrate to more permissive/accurate String parameter types#161
jschillem wants to merge 2 commits intorust-netlink:mainfrom
jschillem:improve-string-params

Conversation

@jschillem
Copy link
Copy Markdown

@jschillem jschillem commented May 9, 2026

The API exclusively accepted String parameters before. This is forcing an unergonomic API for users by forcing them to allocate a String for an internal detail.

This PR changes all APIs that previously accept String into generic impl Into<String> or impl AsRef<Path>. These changes are backwards compatible as String implements both of these trait bounds.

The only breaking change is converting the return type of child_process_create_ns in ns.rs to Result<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 function child_process is not.

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.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread src/ns.rs Outdated
Comment thread src/ns.rs Outdated
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.

1 participant