Skip to main content

CalculatorApp

Struct CalculatorApp 

Source
pub struct CalculatorApp { /* private fields */ }
Expand description

Calculator application state

Implementations§

Source§

impl CalculatorApp

Source

pub fn new() -> Self

Creates a new calculator app with default settings

Source

pub fn with_validator(validator: AnomalyValidator) -> Self

Creates a calculator app with custom Anomaly validator

Source

pub fn input(&self) -> &str

Returns the current input string

Source

pub fn cursor(&self) -> usize

Returns the cursor position

Source

pub fn result(&self) -> Option<&Result<f64, CalcError>>

Returns the last result

Source

pub fn history(&self) -> &History

Returns the calculation history

Source

pub fn should_quit(&self) -> bool

Returns whether the app should quit

Source

pub fn quit(&mut self)

Sets the quit flag

Source

pub fn set_input(&mut self, input: &str)

Sets the input string directly (for testing)

Source

pub fn set_cursor(&mut self, pos: usize)

Sets the cursor position directly (for testing)

Source

pub fn insert_char(&mut self, c: char)

Inserts a character at the cursor position

Source

pub fn delete_char(&mut self)

Deletes the character before the cursor (backspace)

Source

pub fn delete_char_forward(&mut self)

Deletes the character at the cursor (delete key)

Source

pub fn move_cursor_left(&mut self)

Moves the cursor left

Source

pub fn move_cursor_right(&mut self)

Moves the cursor right

Source

pub fn move_cursor_start(&mut self)

Moves cursor to the beginning of input

Source

pub fn move_cursor_end(&mut self)

Moves cursor to the end of input

Source

pub fn clear(&mut self)

Clears the input

Source

pub fn clear_all(&mut self)

Clears everything including history

Source

pub fn evaluate(&mut self)

Evaluates the current input expression

Source

pub fn result_display(&self) -> String

Returns the result as a display string

Source

pub fn recall_last(&mut self)

Loads the last history entry into input

Source

pub fn jidoka_status(&self) -> Vec<String>

Gets the Anomaly status as a display string

Trait Implementations§

Source§

impl Debug for CalculatorApp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CalculatorApp

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.