Skip to main content

EffectSet

Struct EffectSet 

Source
pub struct EffectSet(/* private fields */);
Expand description

the set of effects a function performs.

an empty set IS pure – Pure is implicit, not a stored flag. the u8 repr makes union a single | op, is_subset_of a single mask, and equality a one-byte compare. instances are immutable; every operation returns a fresh EffectSet rather than mutating in place. Copy matters because the type checker stores an EffectSet on every typed function and reads it at every call site; one byte is cheaper to copy than to reference.

Default derives EffectSet(0), which equals EffectSet::pure – the type checker initialises every unannotated function at the bottom of the lattice and unions upward during fixed-point ascent.

Implementations§

Source§

impl EffectSet

Source

pub fn pure() -> Self

the empty set: no flags set, the lattice bottom.

equivalent to is pure annotated functions. constructing a function’s initial EffectSet for fixed-point ascent starts here.

Source

pub fn full() -> Self

every flag set: the lattice top.

used as the upper bound for the unannotated-caller fallback: when the type checker calls a function it cannot resolve a signature for, it treats the call as producing full() so an annotated caller’s check fails closed rather than silently accepting.

Source

pub fn io() -> Self

the singleton set {Io}.

Source

pub fn alloc() -> Self

the singleton set {Alloc}.

Source

pub fn panic() -> Self

the singleton set {Panic}.

Source

pub fn has_io(self) -> bool

is the Io flag set?

Source

pub fn has_alloc(self) -> bool

is the Alloc flag set?

Source

pub fn has_panic(self) -> bool

is the Panic flag set?

Source

pub fn is_pure(self) -> bool

is this the empty set?

true iff no flags are set. an is pure-annotated function’s effect set is exactly this case.

Source

pub fn union(self, other: Self) -> Self

the lattice join: the union of self’s flags and other’s flags.

idempotent (a.union(a) == a), commutative (a.union(b) == b.union(a)), and associative. these properties are what guarantee Plan 4’s fixed-point loop converges monotonically.

Source

pub fn is_subset_of(self, other: Self) -> bool

is every flag set in self also set in other?

reflexive (a.is_subset_of(a) == true), antisymmetric (a ⊆ b and b ⊆ a implies a == b), and transitive. the type checker’s annotation check is inferred.is_subset_of(annotated) – the inferred effect of the body must not exceed what the annotation allows.

Source

pub fn display(&self) -> String

the canonical comma-joined rendering for diagnostics.

flags appear in fixed (Io, Alloc, Panic) order regardless of how the set was constructed, so io().union(alloc()) and alloc().union(io()) both render "io, alloc". an empty set renders "pure". this is the determinism contract the renderer’s byte-identical-output tests depend on.

Trait Implementations§

Source§

impl Clone for EffectSet

Source§

fn clone(&self) -> EffectSet

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EffectSet

Source§

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

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

impl Default for EffectSet

Source§

fn default() -> EffectSet

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

impl Display for EffectSet

Source§

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

delegate to EffectSet::display so format!("{e}") produces the canonical comma-joined form. lets EffectViolation messages interpolate effect sets without an explicit .display() call at every site.

Source§

impl Hash for EffectSet

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for EffectSet

Source§

fn eq(&self, other: &EffectSet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for EffectSet

Source§

impl Eq for EffectSet

Source§

impl StructuralPartialEq for EffectSet

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more