itt-ustutt / num-dual

Generalized (hyper-) dual numbers in rust
Other
53 stars 6 forks source link

Serde serialization feature #73

Closed hyumo closed 5 months ago

hyumo commented 5 months ago

Hi, thanks for this nice lib! Here's a feature request, feel free to close the issue if it's not viable.

Is it possible to add Serde serialization feature to all the Dual number structs?

This would help store data to file, and pass data through network, I am using another crate that requires the Serialize and Deserialize trait. I was suggested to implement my own wrapper struct onto num-dual structs in such cases, but I think it's better to have it within num-dual, otherwise, I have to reimplement all the operator overloadings. Not sure if this makes sense, correct me if there are other better ways to achieve this.

Thx

prehner commented 5 months ago

Hey, thank you for the suggestion. I made a PR in which I added the derive macros for all scalar dual numbers. Do you need vector dual numbers as well? That would be a bit more complicated.

Can you test whether the version in the PR works for your problem? You will need to activate the serde feature to use it

num-dual = { git = "https://github.com/itt-ustutt/num-dual", branch = "serde", features = ["serde"] }
hyumo commented 5 months ago

yep, just tested, it's working for me now.

hyumo commented 5 months ago

feel free to close the issue once merged