Struct MaybeStaticSlice
pub struct MaybeStaticSlice<T: 'static> { /* private fields */ }
A slice that is either 'static or on the heap.
This is useful for representing a sequence of data that can be either created at runtime and put on the heap (when dynamic memory allocation is needed), or when it needs to be constructed at compile time. For example, this is used to represent time zone transitions inside this crate's TZif representation.
The downside of this type is that T cannot contain any borrows.
This is similar to SmallStr, but there is no array-only variant. As such,
this isn't intended for small data. (Indeed, time zone transitions can get
pretty long.) This also makes the API simpler: all constructors are
infallible.
Implementations
impl<T: 'static> MaybeStaticSlice<T>
const fn statik(data: &'static [T]) -> MaybeStaticSlice<T>Creates a new static slice from the data provided.
const fn heap(data: Box<[T]>) -> MaybeStaticSlice<T>Creates a new slice on the heap from the data provided.
const fn as_slice(&self) -> &[T]Returns the underlying data as a slice.
Trait Implementations
impl<T: 'static> Deref for MaybeStaticSlice<T>
type Target = [T];fn deref(&self) -> &[T]
impl<T: 'static> From<&'static [T]> for MaybeStaticSlice<T>
fn from(data: &'static [T]) -> MaybeStaticSlice<T>
impl<T: 'static> From<Box<[T]>> for MaybeStaticSlice<T>
fn from(data: Box<[T]>) -> MaybeStaticSlice<T>
impl<T: Clone + 'static> Clone for MaybeStaticSlice<T>
fn clone(&self) -> Self
impl<T: Debug + 'static> Debug for MaybeStaticSlice<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T: Eq + 'static> Eq for MaybeStaticSlice<T>
impl<T: PartialEq + 'static> PartialEq for MaybeStaticSlice<T>
fn eq(&self, other: &Self) -> bool