Struct Slice

Source
pub struct Slice { /* private fields */ }
Expand description

| Slice is a simple structure containing | a pointer into some external storage and | a size. The user of a Slice must ensure that | the slice is not used after the corresponding | external storage has been deallocated. | | Multiple threads can invoke const methods on | a Slice without external synchronization, but | if any of the threads may call a non-const | method, all threads accessing the same Slice | must use external synchronization.

Implementations§

Source§

impl Slice

Source

pub fn from_ptr_len(d: *const u8, n: usize) -> Self

| Create a slice that refers to d[0,n-1]. |

Source

pub fn data(&self) -> *const u8

| Return a pointer to the beginning of | the referenced data |

Source

pub fn size(&self) -> usize

| Return the length (in bytes) of the referenced | data |

Source

pub fn empty(&self) -> bool

| Return true iff the length of the referenced | data is zero |

Source

pub fn clear(&mut self)

| Change this slice to refer to an empty | array |

Source

pub fn remove_prefix(&mut self, n: usize)

| Drop the first “n” bytes from this slice. |

Source

pub fn to_string(&self) -> String

| Return a string that contains the copy | of the referenced data. |

Source

pub fn starts_with(&self, x: &Slice) -> bool

| Return true iff “x” is a prefix of “*this” |

Source

pub fn compare(&self, b: &Slice) -> i32

| Three-way comparison. Returns value: | < 0 iff “*this” < “b”, | == 0 iff “*this” == “b”, | > 0 iff “*this” > “b”

Trait Implementations§

Source§

impl Default for Slice

Source§

fn default() -> Self

| Create an empty slice. |

Source§

impl From<&String> for Slice

Source§

fn from(s: &String) -> Self

| Create a slice that refers to the contents | of “s” |

Source§

impl From<*const u8> for Slice

Source§

fn from(s: *const u8) -> Self

| Create a slice that refers to s[0,strlen(s)-1] |

Source§

impl Index<usize> for Slice

Source§

fn index(&self, n: usize) -> &Self::Output

| Return the ith byte in the referenced data. | | REQUIRES: n < size()

Source§

type Output = u8

The returned type after indexing.
Source§

impl PartialEq for Slice

Source§

fn eq(&self, other: &Slice) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Slice

Auto Trait Implementations§

§

impl Freeze for Slice

§

impl RefUnwindSafe for Slice

§

impl !Send for Slice

§

impl !Sync for Slice

§

impl Unpin for Slice

§

impl UnwindSafe for Slice

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

Source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> StaticUpcast<T> for T

Source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V