pub struct UChar { /* private fields */ }
Expand description
The implementation of the ICU UChar*
.
While the original type is defined in umachine.h
, most useful functions for manipulating
UChar*
are in fact here.
The first thing you probably want to do is to start from a UTF-8 rust string, produce a UChar.
This is necessarily done with a conversion. See the TryFrom
implementations in this crate
for that.
Implements UChar*
from ICU.
Implementations§
Source§impl UChar
impl UChar
Sourcepub fn new_with_capacity(capacity: usize) -> UChar
pub fn new_with_capacity(capacity: usize) -> UChar
Allocates a new UChar with given capacity.
Capacity and size must always be the same with UChar
when used for interacting with
low-level code.
Sourcepub unsafe fn clone_from_raw_parts(rep: *mut UChar, len: i32) -> UChar
pub unsafe fn clone_from_raw_parts(rep: *mut UChar, len: i32) -> UChar
Creates a new crate::UChar from its low-level representation, a buffer pointer and a buffer size.
Does not take ownership of the buffer that was passed in.
DO NOT USE UNLESS YOU HAVE NO OTHER CHOICE.
§Safety
rep
must point to an initialized sequence of at least len
UChar
s.
Sourcepub fn make_z(&mut self)
pub fn make_z(&mut self)
Converts into a zeroed-out string.
This is a very weird ICU API thing, where there apparently exists a zero-terminated
UChar*
.
Sourcepub fn as_c_ptr(&self) -> *const UChar
pub fn as_c_ptr(&self) -> *const UChar
Returns the constant pointer to the underlying C representation. Intended for use in low-level code.
Sourcepub fn as_mut_c_ptr(&mut self) -> *mut UChar
pub fn as_mut_c_ptr(&mut self) -> *mut UChar
Returns the underlying representation as a mutable C representation. Caller MUST ensure that the representation won’t be reallocated as result of adding anything to it, and that it is correctly sized, or bad things will happen.
Sourcepub fn resize(&mut self, new_size: usize)
pub fn resize(&mut self, new_size: usize)
Resizes this string to match new_size.
If the string is made longer, the new space is filled with zeroes.
Sourcepub fn as_string_debug(&self) -> String
pub fn as_string_debug(&self) -> String
Returns the equivalent UTF-8 string, useful for debugging.
Trait Implementations§
Source§impl TryFrom<&UChar> for String
impl TryFrom<&UChar> for String
Auto Trait Implementations§
impl Freeze for UChar
impl RefUnwindSafe for UChar
impl Send for UChar
impl Sync for UChar
impl Unpin for UChar
impl UnwindSafe for UChar
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)