Struct History

Source
pub struct History {
    pub entries: Vec<HistoryEntry>,
    pub last_result: Option<f64>,
}
Expand description

Represents the history of calculations performed by the calculator.

§Fields

  • entries: A vector of HistoryEntry structs, each representing a single calculation.
  • last_result: An optional floating-point number (Option<f64>) representing the result of the most recent successful calculation.

§Methods

§new

Creates a new, empty History instance.

§add_entry

Adds a new entry to the history.

§Arguments

  • input: A string representing the mathematical expression provided by the user.
  • result: An optional floating-point number representing the result of the calculation. Use None if the calculation failed.
  • error_message: An optional string containing an error message if the calculation failed. Use None if there was no error.

§get_history

Returns a reference to the vector of HistoryEntry structs.

§get_last_result

Returns the result of the most recent successful calculation, or None if no successful calculation has been performed.

Fields§

§entries: Vec<HistoryEntry>§last_result: Option<f64>

Implementations§

Source§

impl History

Represents the history of calculations performed by the calculator.

§Fields

  • entries: A vector of HistoryEntry structs, each representing a single calculation.
  • last_result: An optional floating-point number (Option<f64>) representing the result of the most recent successful calculation.

§Methods

§new

Creates a new, empty History instance.

§add_entry

Adds a new entry to the history.

§Arguments
  • input: A string representing the mathematical expression provided by the user.
  • result: An optional floating-point number representing the result of the calculation. Use None if the calculation failed.
  • error_message: An optional string containing an error message if the calculation failed. Use None if there was no error.
§get_history

Returns a reference to the vector of HistoryEntry structs.

§get_last_result

Returns the result of the most recent successful calculation, or None if no successful calculation has been performed.

Source

pub fn new() -> Self

Source

pub fn add_entry( &mut self, input: String, result: Option<f64>, error_message: Option<String>, )

Source

pub fn get_history(&self) -> &Vec<HistoryEntry>

Source

pub fn get_last_result(&self) -> Option<f64>

Trait Implementations§

Source§

impl Debug for History

Source§

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

Formats the value using the given formatter. 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.