Skip to content

Cyrix126/quote_tool_params

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QUOTE TOOL PARAMS

This very simple library is tool to help manage parameters given as attributs to a derive macro.

Context

For example, this library could be used with this declaration. Consider that struct attribut "params" takes as a string all the parameters that will be used for functions generated by the derive macro and that field attribut "function" will take a function as a string that will be executed when whatever_method_your_trait_bring is called.

trait YourTrait<Args> 
where type Args = Tuple; 
{
  fn whatever_method_your_trait_brings(params: Args);  
}

#[derive(YourTrait)]
#[yourtrait(params = "msg: &str, is_true: bool")]
struct YourStruct {
#[yourtrait(function ="function_name(msg, is_true)")]
  field_a: String
#[yourtrait(function ="other_function(is_true)")]
  field_b: String
}

fn main() {
  let whatever_name = "test";
  let name2 = true;
  YourStruct::whatever_method_your_trait_bring(&(whatever_name, name2));
}

For this to work, you need to pass through the whatever_name and name2 value to the right function. It is where this crate is helpfull. It will give you an easy way to get "&str, bool" to declare your method with a tuple of this elements type, a way to declare variables with corresponding names and values like "let (msg, is_true) = params;" and right names of parameter to give to the function "msg, is_true".

About

Simple library to manager function parameters given to attributs of derive macro.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages