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

Provide a Library::get method that accepts &CStr #163

Open
EFanZh opened this issue Nov 15, 2024 · 1 comment
Open

Provide a Library::get method that accepts &CStr #163

EFanZh opened this issue Nov 15, 2024 · 1 comment

Comments

@EFanZh
Copy link

EFanZh commented Nov 15, 2024

The document of Library::get says that the symbol “may not contain any null bytes, with the exception of the last byte”, which is exactly what CStr is. So I think it is reasonable to provide a get method that accepts &CStr. Changing the current Library::get method is a breaking change, so a new method might need to to be added.

@nagisa
Copy link
Owner

nagisa commented Nov 15, 2024

The bytestring passed in to get is allowed to not contain the trailing null too, but if one is present it must be the last byte. CStr meanwhile requires that the last byte is null. The only reason for the bytestring in this API is because at the time literals (the predominant use-case) could only produce &str or &[u8]. Nowadays there are c literals, so it might actually make sense to change to &CStr.

Breaking changes are not a huge deal, the library is still pre 1.0.

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

No branches or pull requests

2 participants