[−][src]Struct squash::OwnedSlice
An owned slice.
This is similar to Box<[T]>
(or Arc<[T]>
, depending on the Header
H
type parameter).
It holds a heap allocated slice of fixed length. The difference is in internal representation ‒
this is behind a thin pointer and encoded with smaller memory overhead (small slices don't need
full 8 bytes of length).
Examples
use squash::OwnedSlice; let s: OwnedSlice<u16> = OwnedSlice::new(&[1, 2, 3]).unwrap(); assert_eq!(3, s.len());
Internal representation
The heap layout is the header, followed by exactly the number of extra bytes the header needed to encode the length, followed by the actual slice data, with alignments taken into account.
Implementations
impl<T, H> OwnedSlice<T, H> where
H: Header,
[src]
H: Header,
pub fn new(src: &[T]) -> Result<Self, TooLong> where
T: Clone,
[src]
T: Clone,
Creates a new owned slice by cloning a content of the passed one.
Errors
If the slice is bigger than the header can encode, this is signalized by the TooLong
error. Note that the limits of headers provided by this library are generally quite
generous and many users may opt to handle the theoretical errors by unwrapping/panicking.
Trait Implementations
impl<T, H> Clone for OwnedSlice<T, H> where
H: Header,
T: Clone,
[src]
H: Header,
T: Clone,
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T, H> Debug for OwnedSlice<T, H> where
H: Header,
T: Debug,
[src]
H: Header,
T: Debug,
impl<T, H> Default for OwnedSlice<T, H> where
H: Header,
[src]
H: Header,
impl<T, H> Deref for OwnedSlice<T, H> where
H: Header,
[src]
H: Header,
impl<T> DerefMut for OwnedSlice<T, BoxHeader>
[src]
impl<T, H> Drop for OwnedSlice<T, H> where
H: Header,
[src]
H: Header,
impl<T, H> Send for OwnedSlice<T, H> where
H: Header + Send + Sync,
T: Send + Sync,
[src]
H: Header + Send + Sync,
T: Send + Sync,
impl<T, H> Sync for OwnedSlice<T, H> where
H: Header + Send + Sync,
T: Send + Sync,
[src]
H: Header + Send + Sync,
T: Send + Sync,
Auto Trait Implementations
impl<T, H> RefUnwindSafe for OwnedSlice<T, H> where
H: RefUnwindSafe,
T: RefUnwindSafe,
[src]
H: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, H> Unpin for OwnedSlice<T, H> where
T: Unpin,
[src]
T: Unpin,
impl<T, H> UnwindSafe for OwnedSlice<T, H> where
H: RefUnwindSafe,
T: UnwindSafe,
[src]
H: RefUnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,