Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to initialize a record from a Vec with custom struct #315

Open
jayhuang75 opened this issue Apr 27, 2023 · 0 comments
Open

how to initialize a record from a Vec with custom struct #315

jayhuang75 opened this issue Apr 27, 2023 · 0 comments

Comments

@jayhuang75
Copy link

The version I'm using is csv = "1.1.7".
I try to initiate the ByteRecord with Vec.

#[derive(Debug, Serialize, Deserialize)] pub struct CustomStruct { pub type: String, pub name: String, }

Is it possible like this?
let records: Vec<CustomStruct> = vec![CustomStruct{type:"hello".to_string(), name: "world".to_string()}];
let data = ByteRecord::from(records);

However, the error msg is
the trait bound csv::ByteRecord: From<&CustomStruct>is not satisfied the following other types implement traitFrom: <csv::ByteRecord as From<&'a [T]>> <csv::ByteRecord as From<StringRecord>> <csv::ByteRecord as From<Vec<T>>>

Please kindly advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant