Relative Content

Tag Archive for ruststruct

Can I add common fields to different struct definitions in rust?

#[derive(Default, Serialize, Deserialize)] pub struct User { pub id: String, pub username: String, #[serde(rename(serialize = “accountGroupId”, deserialize = “accountGroupId”))] pub account_group_id: String, } #[derive(Default, Serialize, Deserialize)] pub struct Client { pub id: String, pub contact: String, } We need to add common fields such like “enable” to User & Client. Then we can use like […]