-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking Issue for CStr::from_bytes_until_nul #95027
Copy link
Copy link
Closed
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Feature gate:
#![feature(cstr_from_bytes_until_nul)]This is a tracking issue for adding member fn to
CStrthat convert from a byte slice, without the caller needing to know where the nul byte is located within the slice.This is intended for use in FFI calls, where a foreign function wrote a string into a Rust-allocated buffer. The existing member fns fall short in this case:
CStr::from_ptris unsafe and may read past the end of the buffer if no nul byte is found.CStr::from_bytes_with_nulonly works if there is exactly one nul byte at the end of the slice.The proposed new member fn (tentatively named
from_bytes_until_nul) is easier and can be used safely on any byte slice.Public API
Steps / History
CStrmethod that accepts any slice containing a nul-terminated string #94984cstr_from_bytes_until_nul#107429 (comment)cstr_from_bytes_until_nul#107429Unresolved Questions
CStringAPI needs to be designed.CStrmethod that accepts any slice containing a nul-terminated string #94984 (comment) for details.