pub enum TreeNode {
    Atom(String),
    List(Vec<TreeNode>),
}
Expand description

A SISE tree node.

Variants

Atom(String)

An atom, that matches the following regular expression:

"([:atomchar:]|\"(\\([:stringchar:]|\\|\")|[:stringchar:])+\")+"

Where :atomchar: is one of:

!, #, $, %, &, *, +, -, ., /, :, <, =, >, ?, @, _, ~

And :stringchar: is any character between ASCII space and ~, except \ and ".

Atoms are not interpreted in any way, the crate sise_atom provides functions to encode and decode atoms as strings, numbers, booleans…

List(Vec<TreeNode>)

A list of nodes

Implementations

Return whether the node is an Atom.

Return whether the node is a List.

Consumes the node and returns the atom value if it is an Atom.

Consumes the node and returns the list if it is a List.

Returns a reference to the atom value if the node is an Atom.

Returns a reference to the list if the node is a List.

Returns a mutable reference to the atom value if the node is an Atom.

Returns mutable a reference to the list if the node is a List.

Traverses a tree with indices from path.

Example
use sise::sise_tree;

// (example (1 2 3) (a b c))
let tree = sise_tree!(["example", ["1", "2", "3"], ["a", "b", "c"]]);
assert_eq!(*tree.index_path(&[]).unwrap(), tree);
assert_eq!(*tree.index_path(&[0]).unwrap(), "example");
assert_eq!(*tree.index_path(&[1]).unwrap(), sise_tree!(["1", "2", "3"]));
assert_eq!(tree.index_path(&[1, 0]).unwrap(), "1");
assert_eq!(tree.index_path(&[2, 0]).unwrap(), "a");
assert!(tree.index_path(&[3]).is_none());
assert!(tree.index_path(&[0, 1]).is_none());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.