Struct nock::Noun
[−]
[src]
pub struct Noun { /* fields omitted */ }
A Nock noun, the basic unit of representation.
A noun is an atom or a cell. An atom is any natural number. A cell is any ordered pair of nouns.
Atoms are represented by a little-endian byte array of 8-bit digits.
Methods
impl Noun
[src]
fn get<'a>(&'a self) -> NounShape<'a>
Get a shape wrapper for the noun to examine its structure.
fn get_122<'a>(&'a self) -> Option<(&'a Noun, &'a Noun, &'a Noun)>
Pattern-match a noun with shape [p q r].
The digit sequence shows the branch length of each leaf node in the expression being matched. 122 has the leftmost leaf 1 step away from the root and the two leaves on the right both 2 steps away from the root.
fn addr(&self) -> usize
Address of the noun's data in memory, usable as an unique identifier.
Nouns with the same address are always the same, but nouns with different addresses are not guaranteed to have different values.
fn mug(&self) -> u32
fn atom(digits: &[u8]) -> Noun
Build a new atom noun from a little-endian 8-bit digit sequence.
fn cell(a: Noun, b: Noun) -> Noun
Build a new cell noun from two existing nouns.
fn from<T: ToNoun>(item: T) -> Noun
Build a noun from a convertible value.
fn as_u32(&self) -> Option<u32>
Match noun if it's an atom that's a small integer.
Will not match atoms that are larger than 232, but is not guaranteed to match atoms that are smaller than 232 but not by much.
fn fold<'a, F, T>(&'a self, f: F) -> T where
F: FnMut(Shape<&'a [u8], T>) -> T,
T: Clone,
F: FnMut(Shape<&'a [u8], T>) -> T,
T: Clone,
Run a memoizing fold over the noun.
Each noun with an unique memory address will only be processed once, so the fold method allows efficient computation over nouns that may be extremely large logically, but involve a great deal of reuse of the same subnoun objects in practice.
fn print_full(&self, f: &mut Formatter) -> Result
Print the complete noun, even if it's very large.
fn print_abbrev(&self, f: &mut Formatter) -> Result
Print a truncated noun.
Trait Implementations
impl Clone for Noun
[src]
fn clone(&self) -> Noun
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Noun
[src]
fn eq(&self, __arg_0: &Noun) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Noun) -> bool
This method tests for !=
.
impl Eq for Noun
[src]
impl Default for Noun
[src]
impl Hash for Noun
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl FromIterator<Noun> for Noun
[src]
fn from_iter<T>(iterator: T) -> Self where
T: IntoIterator<Item = Noun>,
T: IntoIterator<Item = Noun>,
Creates a value from an iterator. Read more
impl FromNoun for Noun
[src]
impl ToNoun for Noun
[src]
impl FromStr for Noun
[src]
type Err = ParseError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, ParseError>
Parses a string s
to return a value of this type. Read more