2 releases
0.1.1 | Aug 3, 2021 |
---|---|
0.1.0 | Aug 3, 2021 |
#27 in #facilitate
7KB
76 lines
About The Project
Entity Macro to facilitate the implementation of Exercises for a German learning project. It is used on rusty_german
lib.rs
:
RustyEntity
Macro to facilitate the implementation of Exercise Structs. For the struct field is available the properties: description, expected_result, expected_results and sort.
Example
use rusty_german_entity_macro::RustyEntity;
#[derive(RustyEntity)]
struct PrepositionExercise {
#[entity(description)]
prepo: String,
#[entity(expected_result)]
case: String,
}
This will generate a implementation as the following:
use rusty_german_types::Exercise;
struct PrepositionExercise {
prepo: String,
case: String,
}
impl Exercise for PrepositionExercise {
fn get_description(&self) -> String {
self.prepo.to_owned()
}
fn get_expected_result(&self) -> String {
self.case.to_owned()
}
}
Dependencies
~1.5MB
~37K SLoC