-
Notifications
You must be signed in to change notification settings - Fork 208
Add CString
cont.
#549
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
Add CString
cont.
#549
Conversation
src/c_string.rs
Outdated
/// | ||
/// assert_eq!(cstr.to_str(), Ok("hey there")); | ||
/// ``` | ||
pub fn push_bytes(&mut self, bytes: &[u8]) -> Result<(), CapacityError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this extend_from_bytes
or extend_from_slice
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it extend_from_bytes
for now. extend_from_slice
is a bit ambiguous because it might mean either byte or CStr
slices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome stuff @raviqqe !
Co-authored-by: Markus Reiter <me@reitermark.us>
Co-authored-by: Markus Reiter <me@reitermark.us>
Co-authored-by: Markus Reiter <me@reitermark.us>
Co-authored-by: Markus Reiter <me@reitermark.us>
Thanks! |
This PR is a continued work of #342, the heapless implementation of
alloc::ffi::CString
. Credits to @vrmiguel.Closes #330.
Notable changes from the previous PR
Deref<Target = CStr>
forCString
.Default
,AsRef
,Borrow
,PartialEq
,Eq
,PartialOrd
, andOrd
len
andas_str_unchecked
associated functions that should be implemented in the upstream ofcore::ffi::CStr
.push_bytes
associated functionextend_from_bytes
.heapless::Vec
.Future work
heapless::String
interoperabilityCString::into_string
heapless::Vec
interoperabilityCString::from_vec_with_nul
CString::into_bytes
CString::into_bytes_with_nul