pub struct TypeClassRegistry { /* private fields */ }Expand description
The registry that holds all type class and instance declarations.
Implementations§
Source§impl TypeClassRegistry
impl TypeClassRegistry
Sourcepub fn register_class(&mut self, class: TypeClass)
pub fn register_class(&mut self, class: TypeClass)
Register a type class.
Sourcepub fn class_count(&self) -> usize
pub fn class_count(&self) -> usize
Number of registered classes.
Sourcepub fn class_names(&self) -> impl Iterator<Item = &String>
pub fn class_names(&self) -> impl Iterator<Item = &String>
Iterate over all class names.
Sourcepub fn subclasses_of(&self, super_name: &Name) -> Vec<&TypeClass>
pub fn subclasses_of(&self, super_name: &Name) -> Vec<&TypeClass>
Get all classes that extend the given super-class.
Sourcepub fn register_instance(&mut self, instance: Instance)
pub fn register_instance(&mut self, instance: Instance)
Register an instance.
Sourcepub fn find_instances(&self, class: &Name, ty: &Expr) -> Vec<&Instance>
pub fn find_instances(&self, class: &Name, ty: &Expr) -> Vec<&Instance>
Search for instances of the given class for the given type.
Sourcepub fn find_best_instance(
&self,
class: &Name,
ty: &Expr,
) -> InstanceSearchResult
pub fn find_best_instance( &self, class: &Name, ty: &Expr, ) -> InstanceSearchResult
Find the best (highest priority, lowest number) instance.
Sourcepub fn instance_count(&self) -> usize
pub fn instance_count(&self) -> usize
Number of registered instances.
Sourcepub fn clear_local_instances(&mut self)
pub fn clear_local_instances(&mut self)
Remove all local instances.
Sourcepub fn instances_for_class(&self, class: &Name) -> Vec<&Instance>
pub fn instances_for_class(&self, class: &Name) -> Vec<&Instance>
Get all instances for a given class, sorted by priority.
Sourcepub fn filter_instances<F>(&self, predicate: F) -> Vec<&Instance>
pub fn filter_instances<F>(&self, predicate: F) -> Vec<&Instance>
Get instances that match a given type predicate.
Source§impl TypeClassRegistry
impl TypeClassRegistry
Sourcepub fn snapshot(&self) -> RegistrySnapshot
pub fn snapshot(&self) -> RegistrySnapshot
Take a snapshot of the current instance count.
Sourcepub fn restore(&mut self, snapshot: RegistrySnapshot)
pub fn restore(&mut self, snapshot: RegistrySnapshot)
Restore the registry to a previously taken snapshot (removes instances added after).
Trait Implementations§
Source§impl Clone for TypeClassRegistry
impl Clone for TypeClassRegistry
Source§fn clone(&self) -> TypeClassRegistry
fn clone(&self) -> TypeClassRegistry
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TypeClassRegistry
impl Debug for TypeClassRegistry
Source§impl Default for TypeClassRegistry
impl Default for TypeClassRegistry
Source§fn default() -> TypeClassRegistry
fn default() -> TypeClassRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TypeClassRegistry
impl RefUnwindSafe for TypeClassRegistry
impl Send for TypeClassRegistry
impl Sync for TypeClassRegistry
impl Unpin for TypeClassRegistry
impl UnsafeUnpin for TypeClassRegistry
impl UnwindSafe for TypeClassRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more