You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because Rust has the orphan rule, if you use the trait approach, you may encounter issues related to the orphan rule. It becomes challenging to provide serialization functionality for third-party structures.
Recently, referring to the documentation Date in a custom format, I implemented serde_str, and it seems to work well. However, I'm facing difficulties when dealing with Option. Is there a way to combine serde_str and serde_opt? This is quite common.
The code for implementing serde_str for structs that implement the FromStr and ToString traits is as follows:
If I change b: B to b: Option<B>, it seems to introduce new challenges. I'm looking for something like #[serde(with = "serde_opt(serde_str)")], but it appears that such a solution doesn't exist.
This combination of ideas is somewhat reminiscent of how rust-bakery/nom handles things.
The text was updated successfully, but these errors were encountered:
Because Rust has the orphan rule, if you use the trait approach, you may encounter issues related to the orphan rule. It becomes challenging to provide serialization functionality for third-party structures.
Recently, referring to the documentation Date in a custom format, I implemented serde_str, and it seems to work well. However, I'm facing difficulties when dealing with Option. Is there a way to combine serde_str and serde_opt? This is quite common.
The code for implementing serde_str for structs that implement the FromStr and ToString traits is as follows:
Then use as:
If I change
b: B
tob: Option<B>
, it seems to introduce new challenges. I'm looking for something like #[serde(with = "serde_opt(serde_str)")], but it appears that such a solution doesn't exist.This combination of ideas is somewhat reminiscent of how rust-bakery/nom handles things.
The text was updated successfully, but these errors were encountered: