Skip to main content

Instances

Struct Instances 

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

The const stage’s map from canonical name to instantiated module: what makes one name yield one instance.

A caller passes one in and may keep it: within a single load_module it deduplicates the import graph (a diamond shares its instance), and across calls it becomes a host’s module cache, so a module loaded once is not compiled again. Reuse is safe because a name fixes a frame — one name has one set of imports, instantiated leaves-first, so name equality implies frame equality. The cost of keeping it is that a cached name is never recompiled: changed source on disk is not noticed until the entry is dropped.

Implementations§

Source§

impl Instances

Source

pub fn new() -> Instances

An empty map — one compile’s worth of dedup, nothing carried in.

Source

pub fn get(&self, name: &str) -> Option<&Value>

The instance recorded for name, if any.

Source

pub fn insert(&mut self, name: ModuleName, value: Value)

Record value as the instance for name, replacing any earlier one.

Source

pub fn len(&self) -> usize

How many modules the map holds.

Source

pub fn is_empty(&self) -> bool

Whether the map holds no modules.

Source

pub fn names(&self) -> impl Iterator<Item = &ModuleName>

The canonical names the map holds, in insertion order.

Trait Implementations§

Source§

impl Debug for Instances

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Instances

Source§

fn default() -> Instances

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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

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.