[−][src]Struct rustc_metadata::rmeta::Lazy

#[must_use]pub(in rmeta) struct Lazy<T: ?Sized, Meta = <T as LazyMeta>::Meta> where
    T: LazyMeta<Meta = Meta>,
    Meta: 'static + Copy, 
{ position: NonZeroUsize, meta: Meta, _marker: PhantomData<T>, }

A value of type T referred to by its absolute position in the metadata, and which can be decoded lazily.

Metadata is effective a tree, encoded in post-order, and with the root's position written next to the header. That means every single Lazy points to some previous location in the metadata and is part of a larger node.

The first Lazy in a node is encoded as the backwards distance from the position where the containing node starts and where the Lazy points to, while the rest use the forward distance from the previous Lazy. Distances start at 1, as 0-byte nodes are invalid. Also invalid are nodes being referred in a different order than they were encoded in.

Sequences (Lazy<[T]>)

Unlike Lazy<Vec<T>>, the length is encoded next to the position, not at the position, which means that the length doesn't need to be known before encoding all the elements.

If the length is 0, no position is encoded, but otherwise, the encoding is that of Lazy, with the distinction that the minimal distance the length of the sequence, i.e. it's assumed there's no 0-byte element in the sequence.

Fields

position: NonZeroUsizemeta: Meta_marker: PhantomData<T>

Implementations

impl<'a, 'tcx, T: Decodable<DecodeContext<'a, 'tcx>>> Lazy<T>[src]

pub(in rmeta::decoder) fn decode<M: Metadata<'a, 'tcx>>(
    self,
    metadata: M
) -> T
[src]

impl<'a: 'x, 'tcx: 'x, 'x, T: Decodable<DecodeContext<'a, 'tcx>>> Lazy<[T]>[src]

pub(in rmeta::decoder) fn decode<M: Metadata<'a, 'tcx>>(
    self,
    metadata: M
) -> impl ExactSizeIterator<Item = T> + Captures<'a> + Captures<'tcx> + 'x
[src]

impl<I: Idx, T> Lazy<Table<I, T>> where
    Option<T>: FixedSizeEncoding, 
[src]

pub(in rmeta) fn get<'a, 'tcx, M: Metadata<'a, 'tcx>>(
    &self,
    metadata: M,
    i: I
) -> Option<T>
[src]

Given the metadata, extract out the value at a particular index (if any).

pub(in rmeta) fn size(
    &self
) -> usize
[src]

Size of the table in entries, including possible gaps.

impl<T: ?Sized + LazyMeta> Lazy<T>[src]

pub(in rmeta) fn from_position_and_meta(
    position: NonZeroUsize,
    meta: T::Meta
) -> Lazy<T>
[src]

impl<T> Lazy<T>[src]

pub(in rmeta) fn from_position(
    position: NonZeroUsize
) -> Lazy<T>
[src]

impl<T> Lazy<[T]>[src]

pub(in rmeta) fn empty(
) -> Lazy<[T]>
[src]

Trait Implementations

impl<T: ?Sized + LazyMeta> Clone for Lazy<T>[src]

impl<T: ?Sized + LazyMeta> Copy for Lazy<T>[src]

impl<'a, 'tcx, T: Decodable<DecodeContext<'a, 'tcx>>> Decodable<DecodeContext<'a, 'tcx>> for Lazy<T>[src]

impl<'a, 'tcx, T: Decodable<DecodeContext<'a, 'tcx>>> Decodable<DecodeContext<'a, 'tcx>> for Lazy<[T]>[src]

impl<'a, 'tcx, I: Idx, T: Decodable<DecodeContext<'a, 'tcx>>> Decodable<DecodeContext<'a, 'tcx>> for Lazy<Table<I, T>> where
    Option<T>: FixedSizeEncoding, 
[src]

impl<'a, 'tcx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<T>[src]

impl<'a, 'tcx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<[T]>[src]

impl<'a, 'tcx, I: Idx, T: Encodable<EncodeContext<'a, 'tcx>>> Encodable<EncodeContext<'a, 'tcx>> for Lazy<Table<I, T>> where
    Option<T>: FixedSizeEncoding, 
[src]

Auto Trait Implementations

impl<T: ?Sized, Meta> RefUnwindSafe for Lazy<T, Meta> where
    Meta: RefUnwindSafe,
    T: RefUnwindSafe, 

impl<T: ?Sized, Meta> Send for Lazy<T, Meta> where
    Meta: Send,
    T: Send, 

impl<T: ?Sized, Meta> Sync for Lazy<T, Meta> where
    Meta: Sync,
    T: Sync, 

impl<T: ?Sized, Meta> Unpin for Lazy<T, Meta> where
    Meta: Unpin,
    T: Unpin, 

impl<T: ?Sized, Meta> UnwindSafe for Lazy<T, Meta> where
    Meta: UnwindSafe,
    T: UnwindSafe, 

Blanket Implementations

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

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<'a, T> Captures<'a> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone, 
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.