Whoa, yes i missconception about currying, thankyou for your comment, i will edit this ;)
Finally:
#[derive(Debug)] struct States<'a> { a: &'a i32, b: &'a i32, } trait Currying { type ReturnType: Fn(i32) -> i32; fn add(self) -> Self::ReturnType; } impl Currying for States<'static>{ type ReturnType = Box<dyn Fn(i32) -> i32>; fn add(self) -> Self::ReturnType { Box::new(move|x| { x * self.a }) } } let r_value: States = States { a: &100, b: &100 }; let r1 = r_value.add(); let r2 = r1(5); assert_eq!(500, r2);
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Whoa, yes i missconception about currying, thankyou for your comment, i will edit this ;)
Finally: