Crates.io | struct_mapping |
lib.rs | struct_mapping |
version | 1.0.1 |
source | src |
created_at | 2022-10-08 23:41:01.380403 |
updated_at | 2022-10-08 23:46:01.190712 |
description | Token StructMapping for testing StructMapping implementations |
homepage | |
repository | https://github.com/IniterWorker/struct_mapping |
max_upload_size | |
id | 683766 |
size | 19,514 |
StructMapping is a library for create string-based accessors/mutators Rust data structure.
[dependencies]
# The core APIs
struct_mapping = { version = "1.0", features = ["derive"] }
use struct_mapping::{StructMapping, ToStructMappingField};
fn main() {
#[derive(Default)]
struct DeepTestStruct {}
#[derive(StructMapping, Default)]
struct TestStruct {
#[struct_mapping(rename = "jimmy", alias = "jian_yang")]
jian: u32,
#[struct_mapping(skip)]
#[allow(dead_code)]
deep: DeepTestStruct,
}
let mut ex = TestStruct::default();
// print "0"
println!("{}", ex.sm_get("jimmy").unwrap());
ex.sm_set("jimmy", "128").unwrap();
// print "128"
println!("{}", ex.sm_get("jimmy").unwrap());
// print ["jimmy", "jian_yang"]
println!("{:?}", TestStruct::sm_list());
}