Trait swipl::atom::AsAtom

source ·
pub trait AsAtom {
    // Required method
    fn as_atom(&self) -> Atom;

    // Provided method
    fn as_atom_ptr(&self) -> (atom_t, Option<Atom>) { ... }
}
Expand description

Trait for types which can be turned into an Atom from a borrow.

Required Methods§

source

fn as_atom(&self) -> Atom

Turn the borrowed object into an Atom.

The second argument ensures that this function is called in a context where atoms are allowed to be created.

Provided Methods§

source

fn as_atom_ptr(&self) -> (atom_t, Option<Atom>)

Turn the borrowed object into an atom_t, and returns an allocation which will keep this atom_t valid as long as it is not dropped.

This allows code that takes an AsAtom to be a little bit smart about not cloning the underlying data, if the underlying data is already an atom.

Implementations on Foreign Types§

source§

impl AsAtom for str

source§

fn as_atom(&self) -> Atom

source§

impl<'a> AsAtom for &'a str

source§

fn as_atom(&self) -> Atom

Implementors§