pub struct StackCalc { /* private fields */ }Expand description
A simple stack-based calculator for arithmetic expressions.
Implementations§
Source§impl StackCalc
impl StackCalc
Sourcepub fn add(&mut self) -> Option<i64>
pub fn add(&mut self) -> Option<i64>
Adds the top two values and returns the sum, which replaces them.
Returns None, leaving the stack unchanged, if it holds fewer than
two values.
Sourcepub fn sub(&mut self) -> Option<i64>
pub fn sub(&mut self) -> Option<i64>
Subtracts top from second and returns the difference, which replaces
them. Returns None, leaving the stack unchanged, if it holds fewer
than two values.
Trait Implementations§
Auto Trait Implementations§
impl Forget for StackCalc
impl Freeze for StackCalc
impl Move for StackCalc
impl RefUnwindSafe for StackCalc
impl Send for StackCalc
impl Sync for StackCalc
impl Unpin for StackCalc
impl UnsafeUnpin for StackCalc
impl UnwindSafe for StackCalc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more