Skip to main content

Library

Struct Library 

Source
pub struct Library { /* private fields */ }
Expand description

The functions a formula may call, by upper-case name: the seam. Every function registered is a function of its arguments and of the cell it is computed at, and of nothing else: no clock, no chance, no state of its own. An engine’s machine computes a cell again only when a cell it reads has changed (KERNEL.20, super::reach), so a function that answered differently over the same arguments would be computed once and kept.

Implementations§

Source§

impl Library

Source

pub fn empty() -> Library

A library with nothing in it.

Source

pub fn register( &mut self, name: &str, f: fn(&Ctx<'_>, &[Arg<'_>]) -> Result<Value, Reason>, )

Register a strict function; a later registration of the same name replaces the earlier.

Source

pub fn register_form( &mut self, name: &str, f: for<'e> fn(&Ctx<'_>, &'e [Expr]) -> Result<Arg<'e>, Reason>, )

Register a form.

Source

pub fn strict( &self, name: &str, ) -> Option<fn(&Ctx<'_>, &[Arg<'_>]) -> Result<Value, Reason>>

The strict function of that name, without case.

Source

pub fn form( &self, name: &str, ) -> Option<for<'e> fn(&Ctx<'_>, &'e [Expr]) -> Result<Arg<'e>, Reason>>

The form of that name, without case.

Source

pub fn has(&self, name: &str) -> bool

Whether the library holds a function of that name.

Source

pub fn names(&self) -> Vec<&str>

Every name the library holds, sorted.

Source

pub fn len(&self) -> usize

How many functions the library holds.

Source

pub fn is_empty(&self) -> bool

Whether the library holds none.

Trait Implementations§

Source§

impl Default for Library

Source§

fn default() -> Library

Returns the “default value” for a type. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.