Struct sway_ir::irtype::Aggregate

source ·
pub struct Aggregate(pub Index);
Expand description

A collection of Types.

XXX I’ve added Array as using Aggregate in the hope ExtractValue could be used just like with struct aggregates, but it turns out we need ExtractElement (which takes an index Value). So Aggregate can be a ‘struct’ or ‘array’ but you only ever use them with Struct and Array types and with ExtractValue and ExtractElement… so they’re orthogonal and we can simplify aggregate again to be only for structs.

But also to keep Type as Copy we need to put the Array meta into another copy type (rather than recursing with Box, effectively a different Aggregate. This could be OK though, still simpler that what we have here.

NOTE: Aggregate derives Eq (and PartialEq) so that it can also derive Hash. But we must be careful not to use == or != to compare Aggregate for equivalency – i.e., to check that they represent the same collection of types. Instead the is_equivalent() method is provided. XXX Perhaps Hash should be impl’d directly without Eq if possible?

Tuple Fields§

§0: Index

Implementations§

Return a new struct specific aggregate.

Returna new array specific aggregate.

Tests whether an aggregate has the same sub-types.

Get a reference to the [AggregateContent] for this aggregate.

Get the type of (nested) aggregate fields, if found. If an index is into a Union then it will get the type of the indexed variant.

Get the type of the array element, if applicable.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.