Struct CSCDARG

Source
pub struct CSCDARG<'a, FT> { /* private fields */ }
Expand description

CSCDARG is Structure Data Type to Keep Track Parameter Changes Struct for CSCDARG

Implementations§

Source§

impl<'a, FT> CSCDARG<'a, FT>

CSCDARG Self Implement

Source

pub fn new(func: FT) -> CSCDARG<'a, FT>

CSCDARG Constructor CSCDARG::new(wrapper_func)

§example:
  use csclib::*;
  pub fn wrapper<'a>(args:Vec<Box<dyn Any>>)->(&'a str,usize)
    {
      let (a,b,c);
      a=*args[0].downcast_ref::<&str>().unwrap();
      b=*args[1].downcast_ref::<usize>().unwrap();
      c=*args[2].downcast_ref::<usize>().unwrap();
      tfunc(a,b,c)
    }
  pub fn tfunc(a:&str,b:usize,c:usize)->(&str,usize)
    {
      (a,b+b*b+c)
    }
  let itr;
  itr=CSCDARG::new(wrapper)
    .set(("a",""))  // set default value for parameter 'a'
    .set(("b",2_usize)) // set default value for parameter 'b'
    .set(("a","CSC")) // set value for parameter 'a'
    .set(("b",8_usize)) //  set value for parameter 'b'
    .set(("c",3_usize)) // set default value for parameter 'c'
    .set(("c",5_usize)) // set value for parameter 'c'
    .set(("t",13_usize)) // set default value for parameter 't', which never use
    .set(("a",7_i32)) // set invalid value for parameter 'a' which cause panic
    .call(); // return final result of execute wrapper function
  println!("{:?}",itr);
Source

pub fn set<G>(self, arg: (&'a str, G)) -> Self
where G: 'static,

Helper Functon to Set or Modify Position Parameter Each Parameter Have to Follow Position With Format (“parameter_name”,Assigned Repective Value)

§example:
  // --snip-- 
  let itr;
  itr=CSCDARG::new(wrapper)
    .set(("a",""))  // set default value for parameter 'a'
    // --snip-- 
    .set(("t",13_usize)) // set default value for parameter 't', which never use
Source

pub fn call<VT>(self) -> VT
where FT: Fn(Vec<Box<dyn Any>>) -> VT,

Action Functon to Execute Wrapper

§example:
  // --snip-- 
  let itr;
  itr=CSCDARG::new(wrapper)
    .set(("a",""))  // set default value for parameter 'a'
    // --snip-- 
    .set(("t",13_usize)) // set default value for parameter 't', which never use
    .call(); // return final result of execute wrapper function
  println!("{:?}",itr);

Trait Implementations§

Source§

impl<'a, FT: Debug> Debug for CSCDARG<'a, FT>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, FT> Freeze for CSCDARG<'a, FT>
where FT: Freeze,

§

impl<'a, FT> !RefUnwindSafe for CSCDARG<'a, FT>

§

impl<'a, FT> !Send for CSCDARG<'a, FT>

§

impl<'a, FT> !Sync for CSCDARG<'a, FT>

§

impl<'a, FT> Unpin for CSCDARG<'a, FT>
where FT: Unpin,

§

impl<'a, FT> !UnwindSafe for CSCDARG<'a, FT>

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.