-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking Issue for methods to go from nul-terminated Vec<u8> to CString #73179
Copy link
Copy link
Closed
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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 RFCLibs-SmallLibs issues that are considered "small" or self-containedLibs issues that are considered "small" or self-containedLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-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.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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 RFCLibs-SmallLibs issues that are considered "small" or self-containedLibs issues that are considered "small" or self-containedLibs-TrackedLibs issues that are tracked on the team's project board.Libs issues that are tracked on the team's project board.T-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.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The feature gate for the issue is
#![feature(cstring_from_vec_with_nul)].This adds the following method to
CString:FromVecWithNulErroris a new error type, following the naming pattern ofFromBytesWithNulErroralready existing forCStr::new.This type, defined as:
It is inspired from the
FromUtf8Errortype (havingas_bytesandinto_bytesmethod) that allows recuperating the input when conversion failed.The
fmt:Displayimplementation for the type uses the same text as theFromBytesWithNulError, without using the deprecateddescriptionmethod of theErrortrait.Unresolved Questions
CStr::from_bytes_with_nul(and itsuncheckedversion) seems to indicates that having an owned version would be logical.bytestovecin the names (CStr::from_bytes_with_nul->CString::from_vec_with_nulandCStr::from_bytes_with_nul_unchecked->CString::from_vec_with_nul_unchecked).Vec<u8>but I seeCString::newusesInto<Vec<u8>>, should I use that too ?Implementation history
PR #73139 implements this at the moment, in a
unstableform, with documentation and doc tests.PR #89292 by @CleanCut proposes to stabilize this 🥳
Edit: this being the first time I write a tracking issue, please do not hesitate to tell me if there is something to fix.