TypeAggregator

Struct TypeAggregator 

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

Used to aggregate types defined in different Types collections.

A type aggregator can be used to merge compatible definitions of the same type into a single supertype definition stored within the aggregator; this is useful for imports that are shared across different instantiation arguments.

It works by first recursively remapping a type from a foreign Types collection into its own Types collection; any further attempt to aggregate the type causes a merge of type definitions provided they are compatible.

Implementations§

Source§

impl TypeAggregator

Source

pub fn new() -> Self

Creates a new type aggregator.

Source

pub fn types(&self) -> &Types

Gets the aggregator’s type collection.

Source

pub fn imports(&self) -> impl Iterator<Item = (&str, ItemKind)>

Iterates the imported types in the aggregator.

Source

pub fn aggregate( self, name: &str, types: &Types, kind: ItemKind, checker: &mut SubtypeChecker<'_>, ) -> Result<Self>

Aggregates a item kind from a specified type collection using the given import name.

Note that if the aggregate operation fails, the aggregator is consumed.

Trait Implementations§

Source§

impl Debug for TypeAggregator

Source§

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

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

impl Default for TypeAggregator

Source§

fn default() -> TypeAggregator

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.