strunemix
Strunemix allows to build a struct with a form of its fields, by deriving enums of them.
Example
use *;
let person = Person ;
// Attributes names are easiliy turned from or into an array
assert_eq!;
assert_eq!;
assert_eq!;
// Attributes data are turned to an enum
let pseudo_data = Pseudo;
let age_data = Age;
assert_eq!;
// Move between the struct to the form
let mut form = ;
// Set the data to the form
form.set_data;
// or with the name as a string
form.set_data;
// Get the data from the form
let anna = from_form?;
assert_eq!;
If you want to build the attribute data from string values, you must implement the [StrunemixParsableData] trait to handle the conversion from the string data to the struct fields.
// Implement the trait for the enum of names
// Build the attribute data from string values
let pseudo_expected = Pseudo;
let pseudo = "pseudo".?.add_data?;
assert_eq!;
let lois = Person ;
let mut form = lois.;
// Add the data as a string, with the name as an enum or a string
form.set_data_str?;
//or
form.set_data_str?;
License: MIT