Skip to main content

MethodSchema

Struct MethodSchema 

Source
pub struct MethodSchema {
    pub name: &'static str,
    pub generics: &'static [&'static str],
    pub params: &'static [ParamSchema],
    pub variadic: bool,
    pub result: BuiltinType,
    pub mutating: bool,
    pub fresh: bool,
}
Expand description

One builtin method or associated function.

The two are the same shape and differ only in whether there is a receiver, which is what the field they are declared in says: a BuiltinSchema::methods entry is called on a value and a BuiltinSchema::associated entry is called on the type. An associated function therefore never names BuiltinType::SelfType, never names the receiver’s type parameters, and is never mutating.

Fields§

§name: &'static str

The name Cove source calls, such as isEmpty.

§generics: &'static [&'static str]

The type parameters this signature binds of its own, unified at the call site exactly as a declared function’s are.

§params: &'static [ParamSchema]

Parameters in declaration order.

§variadic: bool

Whether the last parameter takes the rest of the arguments, as Vector.of(items: T...) does.

§result: BuiltinType

The type the call produces.

§mutating: bool

Whether the receiver is var self, so the call needs the caller’s own mutable place rather than a value.

§fresh: bool

Whether this call hands back a value nothing else holds a handle to — freshly allocated storage, or a copy of somebody else’s.

cove_sema::unique::creates is the one reader, and this field is the whole of what it trusts: Vector.of(...) allocates, Array.toVector() copies an array’s elements into storage nothing else names, and Vector.snapshot() copies the vector’s own graph, so the three are true. Everything else here is false, including the other types that share snapshot’s declaration — Array.snapshot(), Map.snapshot(), Set.snapshot() and the rest answer themselves, because the type is immutable and “itself” is exactly the handle the caller already had, not a new one.

§Who may say true, and why that is the whole boundary

This table, and only this table. It is the compiler’s own claim about what the runtime allocates, not a declaration a program writes, and crates/cove-runtime/tests/builtin_schema.rs drives every entry through a real interpreter to hold the claim to account. A Cove fn cannot make the same claim about its own return — nothing checks that a body actually hands back unaliased storage — so unique::creates() asks no question of a declared function at all: it resolves a call to an entry in this table or it does not, and a call to a declared function, however it is written or spelled, simply has no entry to resolve to. std.vector.filter’s own out.freeze() is proved the ordinary local way, from Vector.of() a few lines above it in the same body; a caller of filter gets no obligation-free Vector back, before or after this field existed, because the field only ever answers a question about one call’s schema entry, and filter has none.

Implementations§

Source§

impl MethodSchema

Source

pub fn signature(&self) -> String

The signature, in the form it would be written in Cove source: inserted(key: K, value: V) -> Map<K, V>.

Trait Implementations§

Source§

impl Clone for MethodSchema

Source§

fn clone(&self) -> MethodSchema

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 Copy for MethodSchema

Source§

impl Debug for MethodSchema

Source§

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

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

impl Eq for MethodSchema

Source§

impl PartialEq for MethodSchema

Source§

fn eq(&self, other: &MethodSchema) -> 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 StructuralPartialEq for MethodSchema

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.