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 strThe 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: boolWhether the last parameter takes the rest of the arguments, as
Vector.of(items: T...) does.
result: BuiltinTypeThe type the call produces.
mutating: boolWhether the receiver is var self, so the call needs the caller’s own
mutable place rather than a value.
fresh: boolWhether 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§
Trait Implementations§
Source§impl Clone for MethodSchema
impl Clone for MethodSchema
Source§fn clone(&self) -> MethodSchema
fn clone(&self) -> MethodSchema
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for MethodSchema
Source§impl Debug for MethodSchema
impl Debug for MethodSchema
impl Eq for MethodSchema
Source§impl PartialEq for MethodSchema
impl PartialEq for MethodSchema
Source§fn eq(&self, other: &MethodSchema) -> bool
fn eq(&self, other: &MethodSchema) -> bool
self and other values to be equal, and is used by ==.