Skip to main content

FactModifier

Struct FactModifier 

Source
pub struct FactModifier<'env> { /* private fields */ }
Expand description

Collects slot changes and applies them as a single modification.

Aborts on drop unless FactModifier::modify was called, so an abandoned modifier leaves the fact untouched.

Implementations§

Source§

impl<'env> FactModifier<'env>

Source

pub fn integer(&mut self, slot: &str, value: i64) -> Result<&mut Self>

Sets an integer slot.

Source

pub fn float(&mut self, slot: &str, value: f64) -> Result<&mut Self>

Sets a float slot.

Source

pub fn symbol(&mut self, slot: &str, value: &str) -> Result<&mut Self>

Sets a symbol slot.

Source

pub fn string(&mut self, slot: &str, value: &str) -> Result<&mut Self>

Sets a string slot.

Source

pub fn instance_name(&mut self, slot: &str, value: &str) -> Result<&mut Self>

Sets an instance-name slot.

Source

pub fn fact(&mut self, slot: &str, value: &Fact<'env>) -> Result<&mut Self>

Sets a slot to a fact address.

Source

pub fn instance( &mut self, slot: &str, value: &Instance<'env>, ) -> Result<&mut Self>

Sets a slot to an instance address.

Source

pub fn multifield( &mut self, slot: &str, value: &Multifield<'env>, ) -> Result<&mut Self>

Sets a multifield slot.

Source

pub fn value(&mut self, slot: &str, value: &Value<'env>) -> Result<&mut Self>

Assigns an already existing CLIPS value.

Fails with Error::ForeignEnvironment if value belongs to another environment, since CLIPS atoms are interned per environment.

Source

pub fn modify(&mut self) -> Result<Fact<'env>>

Applies the collected changes and returns the resulting fact.

CLIPS retracts the original and asserts a replacement, so the returned fact has a new index and the original reports itself retracted. Slots left unset keep their previous values.

Source

pub fn abort(&mut self)

Discards the collected changes, leaving the fact untouched.

Trait Implementations§

Source§

impl Drop for FactModifier<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'env> !RefUnwindSafe for FactModifier<'env>

§

impl<'env> !Send for FactModifier<'env>

§

impl<'env> !Sync for FactModifier<'env>

§

impl<'env> !UnwindSafe for FactModifier<'env>

§

impl<'env> Freeze for FactModifier<'env>

§

impl<'env> Unpin for FactModifier<'env>

§

impl<'env> UnsafeUnpin for FactModifier<'env>

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.