-
Notifications
You must be signed in to change notification settings - Fork 21
ACP: CStr::is_empty()
#106
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Comments
While I'm not sure about the specific implementation, this API seems worth adding. |
Updated the solution sketch to be less sketch-y. Proposed implementation: jmillikin/upstream__rust@29b261d Docs screenshot: |
This was referenced Sep 28, 2022
This briefly came up in the libs-api meetings. This looks fine to us. :) |
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Oct 11, 2022
…mulacrum Add `is_empty()` method to `core::ffi::CStr`. ACP: rust-lang/libs-team#106 Tracking issue: rust-lang#102444
RalfJung
pushed a commit
to RalfJung/miri
that referenced
this issue
Oct 12, 2022
Add `is_empty()` method to `core::ffi::CStr`. ACP: rust-lang/libs-team#106 Tracking issue: rust-lang/rust#102444
thomcc
pushed a commit
to tcdi/postgrestd
that referenced
this issue
Feb 10, 2023
Add `is_empty()` method to `core::ffi::CStr`. ACP: rust-lang/libs-team#106 Tracking issue: rust-lang/rust#102444
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this issue
May 17, 2023
Stabilize feature `cstr_is_empty` Fixes rust-lang#102444 ACP: rust-lang/libs-team#106
thomcc
pushed a commit
to tcdi/postgrestd
that referenced
this issue
Jul 18, 2023
Stabilize feature `cstr_is_empty` Fixes #102444 ACP: rust-lang/libs-team#106
RalfJung
pushed a commit
to RalfJung/rust-analyzer
that referenced
this issue
Apr 20, 2024
Add `is_empty()` method to `core::ffi::CStr`. ACP: rust-lang/libs-team#106 Tracking issue: rust-lang/rust#102444
RalfJung
pushed a commit
to RalfJung/rust-analyzer
that referenced
this issue
Apr 27, 2024
Add `is_empty()` method to `core::ffi::CStr`. ACP: rust-lang/libs-team#106 Tracking issue: rust-lang/rust#102444
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Uh oh!
There was an error while loading. Please reload this page.
Proposal
Problem statement
The
str
andslice
primitives both haveis_empty()
to check if a value is empty, butCStr
currently doesn't. This is unfortunate because theCStr::to_bytes()
function is documented as performing a length calculation in the future, which would makecstr_val.to_bytes().is_empty()
into an O(N) operation.Motivation, use-cases
There's many reasons a user might want to check if a C string is empty, for example when writing FFI bindings to code written in C that crashes if given an empty string.
Solution sketches
Links and related work
https://rust-for-linux.github.io/docs/kernel/str/struct.CStr.html#method.is_empty
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.
The text was updated successfully, but these errors were encountered: