Enum sise::Node

source ·
pub enum Node {
    Atom(String),
    List(Vec<Box<Node>>),
}
Expand description

A SISE 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<Box<Node>>)

A list of nodes

Implementations§

Bitcasts the reference to self to usize. Useful to insert it in a HashSet<usize>, which is used by sise_encoder::SpacedStyle.

Example
let node = sise::Node::Atom(String::from("example"));
assert_eq!(node.ref_as_usize(), &node as *const sise::Node as usize);

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_expr;

let tree = sise_expr!(["example", ["1", "2", "3"], ["a", "b", "c"]]);
assert_eq!(tree.index_path(&[0]).unwrap(), "example");
assert_eq!(tree.index_path(&[1]).unwrap(), &*sise_expr!(["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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

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
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.