Skip to main content

Subject

Trait Subject 

Source
pub trait Subject {
    type Node: Copy;

    // Required methods
    fn head(&self, node: Self::Node) -> Option<(&str, usize)>;
    fn arg(&self, node: Self::Node, index: usize) -> Self::Node;
    fn int(&self, node: Self::Node) -> Option<i128>;
}
Expand description

The bits of a term the automaton asks about.

A node is whatever the thing doing the matching calls one of its terms: an IR value, an index into an arena, a pointer. It has to be cheap to copy because the walk keeps a stack of them.

Required Associated Types§

Source

type Node: Copy

What this subject calls one of its terms.

Required Methods§

Source

fn head(&self, node: Self::Node) -> Option<(&str, usize)>

The head of a term and how many arguments it has, or nothing if the term is not an application. An IR instruction answers with its opcode and its width, spelled the way the rule file spells it.

Source

fn arg(&self, node: Self::Node, index: usize) -> Self::Node

One argument of a term, counted from zero. Only ever asked for an argument the answer to Subject::head said was there.

Source

fn int(&self, node: Self::Node) -> Option<i128>

The value of a term that is a constant, or nothing if it is not one. This is what a pattern matching a literal is asking, and what a guard reads.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§