MCPcopy Create free account
hub / github.com/bytecodealliance/rustix / as_c_str

Method as_c_str

src/path/dec_int.rs:216–223  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

214 /// Return the raw byte buffer as a `&CStr`.
215 #[inline]
216 pub fn as_c_str(&self) -> &CStr {
217 let bytes_with_nul = self.as_bytes_with_nul();
218 debug_assert!(CStr::from_bytes_with_nul(bytes_with_nul).is_ok());
219
220 // SAFETY: `self.buf` holds a single decimal ASCII representation and
221 // at least one extra NUL byte.
222 unsafe { CStr::from_bytes_with_nul_unchecked(bytes_with_nul) }
223 }
224
225 /// Return the raw byte buffer including the NUL byte.
226 #[inline]

Callers 3

as_cow_c_strMethod · 0.80
into_c_strMethod · 0.80
into_with_c_strMethod · 0.80

Calls 1

as_bytes_with_nulMethod · 0.80

Tested by

no test coverage detected