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

Remove panicking path conversions #64

Merged
merged 4 commits into from
Jul 3, 2024
Merged

Remove panicking path conversions #64

merged 4 commits into from
Jul 3, 2024

Conversation

robin-nitrokey
Copy link
Member

This patch changes all constructors and conversion traits for Path and PathBuf to be fallible (except for From<&Path> for PathBuf). It also adds explicit invariants to the path types and marks its functions as const where possible.

Fixes: #63

Path::from_bytes_with_nul_unchecked was a wrapper for
CStr::from_bytes_with_nul_unchecked and Path::from_cstr_unchecked.
Keeping the two methods separate clearly communicates the requirements
and reduces the likelihood of unsound usage.
To avoid unintended panics and to make it clear which conversions can
fail and which cannot, this patch changes all panicking Path/PathBuf
conversions to return a Result instead.

Fixes: #63
@robin-nitrokey robin-nitrokey merged commit 9a97d10 into main Jul 3, 2024
8 checks passed
@robin-nitrokey robin-nitrokey deleted the path branch July 3, 2024 14:40
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.

Drop or deprecate panicking conversions of paths
2 participants