Is it possible to use serd from structure to structure

For example lets say I have a text file which has a structure:

struct People
name: String,
age: u16,
let person = People{name: "john doe", age: 20};

This is in a text file which is not part of the cargo files.

Now in my, is it possible to to use serd to deserialize this?

I don't know any serde deserializer that would support parsing Rust syntax or a subset thereof[1]. I don't know what you want to parse your example into, but there is the syn crate you could use to do it I guess.

  1. Except serde_tokenstream, but I don't think it is powerful enough to parse your example. ↩ī¸Ž

1 Like

Not with serde, but try include!("filename")

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.