fn binary_fn_in_place_first_arg<U: FnOnce(&mut Self::Elem, &Self::Elem)>(
        &mut self,
        binary_fn: U,
    ) -> Result<(), crate::StackError> {
        if self.len() >= 2 {
            // '.unwrap()' is safe here
            let idx_penultimate = self.len() - 2;
            let penultimate_item = self.container.remove(idx_penultimate);
            binary_fn(self.container.last_mut().unwrap(), &penultimate_item);
            Ok(())
        } else {
            Err(crate::StackError::NotEnoughOperands {
                num_required: 2,
                num_available: self.len(),
            })
        }
    }
/// Appy a binary operation to the two lowermost registers, consuming them and pushing the result.
///
/// # Example
///
/// ```
/// use smsflib::prelude::*;
///
/// let mut stack = DynamicSizedStack::<u32>::clone_from_slice(&[3, 2, 10]);
/// let res = stack.binary_fn_in_place_first_arg(|x: &mut u32, y: &u32| {*x *= y; } );
///
/// assert_eq!(res, Ok(()));
///
/// assert_eq!(stack.len(), 2);
/// assert_eq!(stack.get(0), Some(&20));
/// assert_eq!(stack.get(1), Some(&3));
/// ```
///
/// ```
/// use smsflib::prelude::*;
///
/// let mut stack = DynamicSizedStack::<u32>::clone_from_slice(&[10]);
/// let res = stack.binary_fn_in_place_first_arg(|x: &mut u32, y: &u32| {*x *= y; } );
///
/// assert_eq!(res, Err(smsflib::StackError::NotEnoughOperands{ num_required: 2, num_available: 1 }));
/// ```
///
Appy a binary operation to the two lowermost registers, consuming them and pushing the result.
Appy a binary operation to the two lowermost registers consuming them and pushing the result .
fn binary_fn_in_place_first_arg<U: FnOnce(&mut Self::Elem, &Self::Elem)>(
        &mut self,
        binary_fn: U,
    ) -> Result<(), crate::StackError> {
        if self.len() >= 2 {
            // '.unwrap()' is safe here
            let idx_penultimate = self.len() - 2;
            let penultimate_item = self.container.remove(idx_penultimate);
            binary_fn(self.container.last_mut().unwrap(), &penultimate_item);
            Ok(())
        } else {
            Err(crate::StackError::NotEnoughOperands {
                num_required: 2,
                num_available: self.len(),
            })
        }
    }
fn binary_fn_in_place_first_arg < U : FnOnce ( & mut Self :: Elem , & Self :: Elem ) > ( & mut self , binary_fn : U , ) -> Result < ( ) , crate :: StackError > { if self . len ( ) >= 2 { // '.unwrap()' is safe here let idx_penultimate = self . len ( ) - 2 ; let penultimate_item = self . container . remove ( idx_penultimate ) ; binary_fn ( self . container . last_mut ( ) . unwrap ( ) , & penultimate_item ) ; Ok ( ( ) ) } else { Err ( crate :: StackError :: NotEnoughOperands { num_required : 2 , num_available : self . len ( ) , } ) } }
Appy a binary operation to the two lowermost registers, consuming them and pushing the result.
Appy a binary operation to the two lowermost registers consuming them and pushing the result .
&mut self
binary_fn
U
example
```
use smsflib::prelude::*.







```
use smsflib::prelude::*.

let mut stack = DynamicSizedStack::::clone_from_slice(&[10]);
let res = stack.binary_fn_in_place_first_arg(|x: &mut u32, y: &u32| {*x *= y; } ).

assert_eq!(res, Err(smsflib::StackError::NotEnoughOperands{ num_required: 2, num_available: 1 }));
```
` ` ` use smsflib :: prelude :: * . ` ` ` use smsflib :: prelude :: * . let mut stack = DynamicSizedStack :::: clone_from_slice ( & [ 10 ] ) ; let res = stack . binary_fn_in_place_first_arg ( |x : &mut u32 y : &u32| { * x * = y ; } ) . assert_eq! ( res Err ( smsflib :: StackError :: NotEnoughOperands { num_required : 2 num_available : 1 } )) ; ` ` `