Trait swipl::term::TermPutable
source · pub unsafe trait TermPutable {
// Required method
fn put(&self, term: &Term<'_>);
}
Expand description
Trait for putting data into a term reference.
Unlike unification, putting data into a term replaces the term entirely. This is a non-logical operation that doesn’t play nice with backtracking. You’re generally better off using unification.
Safety
This is marked unsafe because in order to do term putting, we must be sure that
- the term is created on the engine which is currently active
- the given context is a context for this engine
Not checking those preconditions results in undefined
behavior. Therefore, care must be taken to ensure that put
is
actually safe.
The macro [term_putable!] provides a way to safely implement this trait by doing the precondition checks for you.