pub struct MethodCatalog { /* private fields */ }Expand description
The finalized method catalog: an ordered, duplicate-free list of entries.
Implementations§
Source§impl MethodCatalog
impl MethodCatalog
Sourcepub fn build() -> MethodCatalogBuilder
pub fn build() -> MethodCatalogBuilder
Begin a builder. The builder is the only way to add entries, and its
finish step enforces uniqueness.
Sourcepub fn entries(&self) -> &[MethodEntry]
pub fn entries(&self) -> &[MethodEntry]
All entries, in insertion order.
Sourcepub fn by_receiver_and_name<'a>(
&'a self,
receiver: &'a TypePattern,
name: &'a str,
) -> impl Iterator<Item = &'a MethodEntry> + 'a
pub fn by_receiver_and_name<'a>( &'a self, receiver: &'a TypePattern, name: &'a str, ) -> impl Iterator<Item = &'a MethodEntry> + 'a
Entries whose (receiver, name) match, in insertion order. The caller
disambiguates by arity at the call site.
Sourcepub fn has_name_at_arity(&self, name: &str, arity: usize) -> bool
pub fn has_name_at_arity(&self, name: &str, arity: usize) -> bool
Does any receiver in the catalog have a method name taking arity
arguments?
The predicate lives here rather than at the call site because its
justification is a fact about this table: the catalog is the complete
method universe of the language. A record carries no rows (p.len() on
struct P { len: Int } is a missing method, not a field read), an enum
carries none, and there is no user impl — so a name this table does not
hold at that arity can never resolve against any receiver, known or
not yet known.
That is what lets inference refuse fn f(x) { x.nope() } before anything
says what x is (ADR-093). The complementary half matters just as much:
a name the table does hold — sum, at arity 0 — is left deferred even
though no receiver is known, because §5.2’s fn total(values) { values.sum() } must still infer. Spelling the predicate as “no row
matches this receiver” instead would reject that program.
If this language ever grows user-defined methods, this predicate loses its justification and ADR-093’s Rule B has to go with it.
Trait Implementations§
Source§impl Clone for MethodCatalog
impl Clone for MethodCatalog
Source§fn clone(&self) -> MethodCatalog
fn clone(&self) -> MethodCatalog
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more