#[repr(C)]pub struct String {
pub ptr: *const u8,
pub len: usize,
}Expand description
A borrowed byte string (pointer + length).
The memory is not owned by this struct. The pointer is only valid for the lifetime documented by the API that produces or consumes it.
Fields§
§ptr: *const u8Pointer to the string bytes.
len: usizeLength of the string in bytes.
Implementations§
Source§impl String
impl String
Sourcepub unsafe fn to_bytes<'a>(self) -> &'a [u8] ⓘ
pub unsafe fn to_bytes<'a>(self) -> &'a [u8] ⓘ
Borrow the string as raw bytes. A null pointer is treated as an empty
string; the C API does not promise a non-null pointer for zero-length
strings, and slice::from_raw_parts requires one even at length zero.
§Safety
The caller must uphold that the associated lifetime is valid with the given context behind the FFI string.
Trait Implementations§
impl Copy for String
Auto Trait Implementations§
impl !Send for String
impl !Sync for String
impl Freeze for String
impl RefUnwindSafe for String
impl Unpin for String
impl UnsafeUnpin for String
impl UnwindSafe for String
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