Is there some equivalent of JS's Object.keys() for Rust's struct?
I need something to generate CSV headers (I use rust-csv) from structure field names.
struct Export {
first_name: String,
last_name: String,
gender: String,
date_of_birth: String,
address: String
}
//... some code
let mut wrtr = Writer::from_file("/home/me/export.csv").unwrap().delimiter(b'\t');
wrtr.encode(/* WHAT TO WRITE HERE TO GET STRUCT NAMES as tuple of strings or somethings */).is_ok()
Aucun commentaire:
Enregistrer un commentaire