struct InputOutput {
    input_text: Vec<char>,
    text_index: usize,
    output_text: String,
}
Expand description

Represents an input string and an output string, along with an index into the input string. This is used for running the individual characters of the input through the finite state machine to produce filtered output.

(Normally, the input and output would appear on the StateContext struct, however, there was a circular reference between the IStateContext trait and the IStateBehavior::go_next() method, resulting in an error where a mutable borrow was occurring on an already mutable borrow. Only way around this was to separate the input/output stuff from the context stuff.)

Fields§

§input_text: Vec<char>

Text to be filtered. The given text is converted to a vector so it can be indexed, allowing us to easily detect end of string.

§text_index: usize

Index into the input text.

§output_text: String

The output string that accumulates the filtered text.

Implementations§

source§

impl InputOutput

source

fn new(input_text: &str) -> InputOutput

Constructor

Parameters
  • input_text

    The text to be filtered.

Returns

Returns a new instance of the InputOutput struct.

Trait Implementations§

source§

impl IStateContext for InputOutput

source§

fn get_next_character(&mut self) -> StateChar

Get the next character from the input. Read more
source§

fn output_character(&mut self, character: StateChar)

Write the character to the context. This is how the parser accumulates the filtered text. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V