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

ffi: simplify FromBytesWithNulError in core::c_str #132731

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ohno418
Copy link
Contributor

@ohno418 ohno418 commented Nov 7, 2024

FromBytesWithNulError is a struct that only contains kind: FromBytesWithNulErrorKind, which is an enum. This representation is somewhat redundant.

Make FromBytesWithNulError an enum that is equivalent to current FromBytesWithNulErrorKind in order to simplify. Additionally, add docs for the enum members.

Note that this change aligns FromBytesWithNulError more closely with CStrConvertError in the Linux kernel 1, which will utilize rustc's CStr in the future.

`FromBytesWithNulError` is a struct that only contains `kind:
FromBytesWithNulErrorKind`, which is an enum. This representation is
somewhat redundant.

Make `FromBytesWithNulError` an enum that is equivalent to current
`FromBytesWithNulErrorKind` in order to simplify. Additionally, add docs
for the enum members.

Note that this change aligns `FromBytesWithNulError` more closely with
`CStrConvertError` in the Linux kernel [1], which will utilize rustc's
`CStr` in the future.

[1]: https://github.com/Rust-for-Linux/linux/blob/ae7851c29747fa3765ecb722fe722117a346f988/rust/kernel/str.rs#L130-L138
@rustbot
Copy link
Collaborator

rustbot commented Nov 7, 2024

r? @Noratrieb

rustbot has assigned @Noratrieb.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 7, 2024

#[derive(Clone, PartialEq, Eq, Debug)]
enum FromBytesWithNulErrorKind {
pub enum FromBytesWithNulError {
Copy link
Member

@Noratrieb Noratrieb Nov 7, 2024

Choose a reason for hiding this comment

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

this makes the precise enum variants part of the public interface, which we don't want. that's why it's a private field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants