[][src]Struct lumberjack::io::AbsoluteEncoding

pub struct AbsoluteEncoding(_);

Absolute Encoding.

Trees are encoded as a sequence of tuples:

  • For each token a the common nonterminal label with the following token and the number of common nonterminal nodes.
  • Optional leaf unary chains.

Methods

impl AbsoluteEncoding[src]

pub fn new(inner: Vec<(Option<AbsoluteAncestor>, Option<String>)>) -> Self[src]

pub fn try_from_relative(encoding: RelativeEncoding) -> ConversionResult[src]

Fallible conversion from RelativeEncoding.

Returns: * ConversionResult::Success if conversion was succesful or * ConversionResult::Error if an error was encountered.

Errors are recoverable, and can be fixed by e.g.:

use lumberjack::io::{AbsoluteEncoding, Encode, PTBFormat};

let tree = PTBFormat::Simple.string_to_tree("(Some (Test tree))").unwrap();
let rel_encoding = tree.encode_relative().unwrap();
let abs_encoding = AbsoluteEncoding::try_from_relative(rel_encoding).unwrap_or_fix();;

Methods from Deref<Target = Vec<(Option<AbsoluteAncestor>, Option<String>)>>

pub fn capacity(&self) -> usize1.0.0[src]

Returns the number of elements the vector can hold without reallocating.

Examples

let vec: Vec<i32> = Vec::with_capacity(10);
assert_eq!(vec.capacity(), 10);

pub fn as_slice(&self) -> &[T]1.7.0[src]

Extracts a slice containing the entire vector.

Equivalent to &s[..].

Examples

use std::io::{self, Write};
let buffer = vec![1, 2, 3, 5, 8];
io::sink().write(buffer.as_slice()).unwrap();

pub fn len(&self) -> usize1.0.0[src]

Returns the number of elements in the vector, also referred to as its 'length'.

Examples

let a = vec![1, 2, 3];
assert_eq!(a.len(), 3);

pub fn is_empty(&self) -> bool1.0.0[src]

Returns true if the vector contains no elements.

Examples

let mut v = Vec::new();
assert!(v.is_empty());

v.push(1);
assert!(!v.is_empty());

Trait Implementations

impl PartialEq<AbsoluteEncoding> for AbsoluteEncoding[src]

impl From<AbsoluteEncoding> for RelativeEncoding[src]

impl Clone for AbsoluteEncoding[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl IntoIterator for AbsoluteEncoding[src]

type Item = (Option<AbsoluteAncestor>, Option<String>)

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

impl Debug for AbsoluteEncoding[src]

impl Deref for AbsoluteEncoding[src]

type Target = Vec<(Option<AbsoluteAncestor>, Option<String>)>

The resulting type after dereferencing.

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]