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
impl InputOutput
sourcefn new(input_text: &str) -> InputOutput
fn new(input_text: &str) -> InputOutput
Constructor
Parameters
-
input_text
The text to be filtered.
Returns
Returns a new instance of the InputOutput struct.