-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Creating CString from nul-terminated data #73100
Copy link
Copy link
Closed
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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.
Metadata
Metadata
Assignees
Labels
A-FFIArea: Foreign function interface (FFI)Area: Foreign function interface (FFI)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
It seems there's no idiomatic way to create
CStringfrom nul-terminatedVec<u8>. The only approriate way is topop()last nul and thenfrom_vec_uncheckedwill append a new one. Need the method just passes data as is (e.g.CString::from_vec_with_nulsuch asCStr::from_bytes_with_nul).Possibly, code should be like:
and safe version: