https://github.com/cyrix126/quote_tool_params
Simple library to manager function parameters given to attributs of derive macro.
https://github.com/cyrix126/quote_tool_params
Last synced: about 2 months ago
JSON representation
Simple library to manager function parameters given to attributs of derive macro.
- Host: GitHub
- URL: https://github.com/cyrix126/quote_tool_params
- Owner: Cyrix126
- License: gpl-3.0
- Created: 2024-01-26T09:20:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-04T15:38:36.000Z (over 2 years ago)
- Last Synced: 2024-02-05T12:33:15.967Z (over 2 years ago)
- Language: Rust
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```rust,ignore
trait YourTrait
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".