Derive Macro WriteToTree

Source
#[derive(WriteToTree)]
Available on crate feature derive only.
Expand description

Derive macro available if oxyroot is built with features = ["derive"].

Derive macro in order to write struct data into a TTree. Branch names and types are deduced from fields.

use oxyroot::{WriteToTree, RootFile};
#[derive(WriteToTree)]
struct MyStruct {
    a: i32,     // will be read from branch "a" as 32 bits integer
    s: String,  // will be read from branch "s" String
}
let mut f = RootFile::create("out.root").unwrap();
let mut tree = oxyroot::WriterTree::new("tree");
let it = vec![MyStruct {a: 0,s: "a".to_string()}, MyStruct {a: 1,s: "b".to_string()}].into_iter();
MyStruct::to_tree(it, &mut tree).unwrap();
tree.write(&mut f).unwrap();
f.close().unwrap();