Skip to main content

ClassSignature

Struct ClassSignature 

Source
pub struct ClassSignature {
    pub variable: Name,
    pub superclasses: Vec<Constraint>,
    pub members: Vec<Member>,
    pub derivations: Vec<Derivation>,
    pub derivations_rejected: bool,
    pub span: NodeSpan,
}
Expand description

What a class declares that another module can see: its members and superclasses, and the derivations it carries.

It is what Interface::classes carries for each class a module exposes, and what an importer checks an instance of that class against. The derivations are in it because a derived instance is usually written beside its type, in a module other than the class’s, and its members are written out of the bindings there.

Fields§

§variable: Name

The class variable, a in class Comparable a where.

§superclasses: Vec<Constraint>

The superclasses, each a constraint on variable.

§members: Vec<Member>

The member signatures, in the order written.

§derivations: Vec<Derivation>

The derivations that passed every check, in the order written, at most one per member. A derivation that did not is reported and is not here, so the member it was for is one this class does not derive.

§derivations_rejected: bool

Whether the module that declares the class rejected one of its derivations: one did not pass the checks a derivation is held to, the class derives some of its members and not the rest, or the type checker rejected one’s binding. That module has reported why, so an instance asking to be derived is not told again that the class is not derivable, and a derived instance’s members do not report the type error a second time.

§span: NodeSpan

Where the head line was written, class through where.

Implementations§

Source§

impl ClassSignature

Source

pub fn derivation(&self, member: &Name) -> Option<&Derivation>

The derivation of member, when it has one.

Source

pub fn derivable(&self) -> bool

Whether an instance of this class may be derived: every member carries a derivation. A class with no member has nothing to derive and is not.

Source

pub fn walks_one_value(&self) -> bool

Whether some member’s derivation walks one value, which a () has no element to begin at.

Trait Implementations§

Source§

impl Clone for ClassSignature

Source§

fn clone(&self) -> ClassSignature

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 ClassSignature

Source§

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

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

impl PartialEq for ClassSignature

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ClassSignature

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