#compile-time #reflection #hacky #testing

macro reflective

Hacky compile-time reflection

1 unstable release

0.1.0 Feb 21, 2019

#2351 in Procedural macros

MIT license

7KB
110 lines

use reflective::{reflective};

#[reflective]
pub struct TestStruct{
    name: &'static str,
}

#[test]
fn reflection(){
    let s = &mut TestStruct{
        name: "sam",
    };
    let mut res : &str = TestStruct::get_field(s, "name");
    assert_eq!(res, "sam");
    TestStruct::set_field(s, "name", "mas");
    assert_eq!(s.name, "mas");
}

No runtime deps