pub struct SourceSlice { /* private fields */ }Expand description
A validated zero-copy view of owner’s bytes over [start, start + len).
The fields are private and SourceSlice::new is the only constructor,
because the range is not a hint: a view whose end runs past the owner, or
whose ends fall inside a multi-byte scalar, is not a Text. Neither is
constructible, so bad ranges cannot surface far from their cause as an
out-of-range slice or as a Text that reads empty.
#[repr(C)] fixes the field order, so the payload layout is stable.
Implementations§
Source§impl SourceSlice
impl SourceSlice
Sourcepub unsafe fn new(owner: GcRef, start: usize, len: usize) -> Option<SourceSlice>
pub unsafe fn new(owner: GcRef, start: usize, len: usize) -> Option<SourceSlice>
A view of owner’s bytes over [start, start + len), or None if that
is not a Text: a range past the end, a length that overflows, or ends
that are not UTF-8 scalar boundaries.
§Safety
owner must be a live Text GcRef — its payload is read to validate
the range.
Trait Implementations§
Source§impl Clone for SourceSlice
impl Clone for SourceSlice
Source§fn clone(&self) -> SourceSlice
fn clone(&self) -> SourceSlice
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for SourceSlice
Auto Trait Implementations§
impl !RefUnwindSafe for SourceSlice
impl !Send for SourceSlice
impl !Sync for SourceSlice
impl !UnwindSafe for SourceSlice
impl Freeze for SourceSlice
impl Unpin for SourceSlice
impl UnsafeUnpin for SourceSlice
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