pub struct WStrBuf<const N: usize>(/* private fields */);Expand description
A fixed-size UTF-16 string buffer inside a struct (wchar_t name[N]),
holding a string up to the first NUL.
§Examples
use imping_runtime::WStrBuf;
let mut name = WStrBuf::<4>::new();
name.set("Héllo");
assert_eq!(name.to_string_lossy(), "Hél"); // at most 3 code units, then the NULImplementations§
Source§impl<const N: usize> WStrBuf<N>
impl<const N: usize> WStrBuf<N>
Sourcepub fn to_wide(&self) -> &[u16]
pub fn to_wide(&self) -> &[u16]
Returns the string’s UTF-16 code units: up to the first NUL, or the whole buffer if it has none.
Sourcepub fn to_string_lossy(&self) -> String
pub fn to_string_lossy(&self) -> String
Returns the string as UTF-8, with unpaired surrogates replaced by �.
Sourcepub fn set(&mut self, value: &str)
pub fn set(&mut self, value: &str)
Stores value as UTF-16, truncated to fit before the terminating NUL.
Truncation never splits a surrogate pair. A NUL in value ends it, and
the rest of the buffer is zeroed.
Sourcepub fn as_array_mut(&mut self) -> &mut [u16; N]
pub fn as_array_mut(&mut self) -> &mut [u16; N]
Returns the whole buffer, to write to it directly.
Trait Implementations§
impl<const N: usize> Copy for WStrBuf<N>
impl<const N: usize> Eq for WStrBuf<N>
impl<const N: usize> Plain for WStrBuf<N>
impl<const N: usize> StructuralPartialEq for WStrBuf<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for WStrBuf<N>
impl<const N: usize> RefUnwindSafe for WStrBuf<N>
impl<const N: usize> Send for WStrBuf<N>
impl<const N: usize> Sync for WStrBuf<N>
impl<const N: usize> Unpin for WStrBuf<N>
impl<const N: usize> UnsafeUnpin for WStrBuf<N>
impl<const N: usize> UnwindSafe for WStrBuf<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more