Skip to content

rust: CStr overhaul - #273

Merged
ojeda merged 3 commits into
Rust-for-Linux:rustfrom
nbdd0121:cstr_v2
May 26, 2021
Merged

ojeda merged 3 commits into
Rust-for-Linux:rustfrom
nbdd0121:cstr_v2

Conversation

@nbdd0121

Copy link
Copy Markdown
Member

CStr is overhauled to make using it more similar to use a str.

This is split from #258, without procedural macros and CBoundedStr and does not depend on build_assert!.

Some additional improvements:

  • Added a BStr which is just [u8] but provide an extra semantical annotation;
  • Make CStr deref toBStr so many functions could be used;
  • Add AsRef<BStr> for CStr, combining with deref this allows CStr to be used when &BStr is exepcted;
  • Allow CStr to be sliced like a [u8];
  • Change c_string_bytes to CStr::from_char_ptr

r? @ojeda @wedsonaf

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants