So I have several functions in a struct which return a value:
fn a(&mut self) -> u8{
//Do stuff
return 0;
}
fn b(z: u8) -> u8{return z;}
fn c(&mut self) -> u8{
//Do stuff
return 2;
}
I want to know if there is a way to call a function from an array which can be accessed by other member for functions, so, for example:
static FUNCTIONS: [u8; 3] = [a(), b(some_value), c()];
// OR
let functions: [u8; 3] = [a(), b(some_value), c()];
So in summation, I would like to do something like this:
struct this_struct {
value:u8
}
impl this_struct {
// The array of functions could be placed here for member access
fn a(&mut self) -> u8{
//Do stuff with value
return 0;
}
fn b(z: u8) -> u8{return z;}
fn c(&mut self) -> u8{
//Do stuff with value
return 2;
}
}
Basically, I just want to know if there is a way to call a function of a struct from an array in a way which will modify the struct's member variable. Is this possible? If so, how and where should I place the array?
valueinb(value)? ShouldFUNCTIONSbe per-object? Orvaluesome known constant?