Struct naga::compact::handle_set_map::HandleMap

source ·
pub struct HandleMap<T> {
    new_index: Vec<Option<NonMaxU32>>,
    as_keys: PhantomData<T>,
}
Expand description

A map from old handle indices to new, compressed handle indices.

Fields§

§new_index: Vec<Option<NonMaxU32>>

The indices assigned to handles in the compacted module.

If new_index[i] is Some(n), then n is the Index of the compacted Handle corresponding to the pre-compacted Handle whose index is i.

§as_keys: PhantomData<T>

This type is indexed by values of type T.

Implementations§

source§

impl<T: 'static> HandleMap<T>

source

pub fn from_set(set: HandleSet<T>) -> Self

source

pub fn used(&self, old: Handle<T>) -> bool

Return true if old is used in the compacted module.

source

pub fn try_adjust(&self, old: Handle<T>) -> Option<Handle<T>>

Return the counterpart to old in the compacted module.

If we thought old wouldn’t be used in the compacted module, return None.

source

pub fn adjust(&self, handle: &mut Handle<T>)

Return the counterpart to old in the compacted module.

If we thought old wouldn’t be used in the compacted module, panic.

source

pub fn adjust_option(&self, handle: &mut Option<Handle<T>>)

Like adjust, but for optional handles.

source

pub fn adjust_range(&self, range: &mut Range<T>, compacted_arena: &Arena<T>)

Shrink range to include only used handles.

Fortunately, compaction doesn’t arbitrarily scramble the expressions in the arena, but instead preserves the order of the elements while squeezing out unused ones. That means that a contiguous range in the pre-compacted arena always maps to a contiguous range in the post-compacted arena. So we just need to adjust the endpoints.

Compaction may have eliminated the endpoints themselves.

Use compacted_arena to bounds-check the result.

Auto Trait Implementations§

§

impl<T> Freeze for HandleMap<T>

§

impl<T> RefUnwindSafe for HandleMap<T>
where T: RefUnwindSafe,

§

impl<T> Send for HandleMap<T>
where T: Send,

§

impl<T> Sync for HandleMap<T>
where T: Sync,

§

impl<T> Unpin for HandleMap<T>
where T: Unpin,

§

impl<T> UnwindSafe for HandleMap<T>
where T: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.