mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-01 06:20:34 +00:00
Revert "Refactor unsafe constructor"
This reverts commit 55c7996aba3341501aa3843bd6e756e023f1814e.
This commit is contained in:
parent
ccbff00dba
commit
10954469b3
@ -72,11 +72,11 @@ impl<const N: usize> CString<N> {
|
||||
/// assert_eq!(cstr.to_str(), Ok("cstr"));
|
||||
/// ```
|
||||
pub unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> Result<Self, CapacityError> {
|
||||
let mut string = Self::new();
|
||||
let mut vec = Vec::new();
|
||||
|
||||
string.push_bytes(bytes)?;
|
||||
vec.extend_from_slice(bytes)?;
|
||||
|
||||
Ok(string)
|
||||
Ok(Self { vec })
|
||||
}
|
||||
|
||||
/// Instantiates a [`CString`] copying from the giving byte slice, assuming it is
|
||||
|
Loading…
x
Reference in New Issue
Block a user