File tree 2 files changed +2
-8
lines changed
2 files changed +2
-8
lines changed Original file line number Diff line number Diff line change 19
19
const_fn_trait_bound,
20
20
const_mut_refs,
21
21
const_panic,
22
- const_raw_ptr_deref ,
22
+ const_fn_transmute ,
23
23
const_unreachable_unchecked,
24
24
doc_cfg,
25
25
ptr_metadata,
Original file line number Diff line number Diff line change @@ -146,14 +146,8 @@ impl CStr {
146
146
/// `NUL` byte (or the string will be truncated).
147
147
#[ inline]
148
148
pub const unsafe fn from_bytes_with_nul_unchecked ( bytes : & [ u8 ] ) -> & CStr {
149
- // Note: This can be done using pointer deref (which requires
150
- // `const_raw_ptr_deref` to be const) or `transmute` (which requires
151
- // `const_transmute` to be const) or `ptr::from_raw_parts` (which
152
- // requires `ptr_metadata`).
153
- // While none of them are current stable, it is very likely that one of
154
- // them will eventually be.
155
149
// SAFETY: Properties of `bytes` guaranteed by the safety precondition.
156
- unsafe { & * ( bytes as * const [ u8 ] as * const Self ) }
150
+ unsafe { core :: mem :: transmute ( bytes) }
157
151
}
158
152
159
153
/// Returns a C pointer to the string.
You can’t perform that action at this time.
0 commit comments