Skip to content

Commit

Permalink
Inline CStr::from_bytes_with_nul_unchecked::rt_impl
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilaBorowska committed Aug 10, 2022
1 parent 1603a70 commit de95117
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ impl CStr {
#[rustc_const_stable(feature = "const_cstr_unchecked", since = "1.59.0")]
#[rustc_allow_const_fn_unstable(const_eval_select)]
pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr {
#[inline]
fn rt_impl(bytes: &[u8]) -> &CStr {
// Chance at catching some UB at runtime with debug builds.
debug_assert!(!bytes.is_empty() && bytes[bytes.len() - 1] == 0);
Expand Down

0 comments on commit de95117

Please sign in to comment.