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

Serializing #186

Closed
jeff-hykin opened this issue Apr 25, 2021 · 3 comments
Closed

Serializing #186

jeff-hykin opened this issue Apr 25, 2021 · 3 comments
Labels

Comments

@jeff-hykin
Copy link

I took a look at the related PR: #158
And found the serde_seq, but didn't see how to apply it outside of a struct.

I'm just trying to serialize an index map. The project is for helping me learn rust, so I don't have a ton of experience.
Using HashMap in place of IndexMap works, other than the fact that I need keys to be in order.

It looks from the PR that you have implmented Serialize, so I don't fully understand why rust is complaining about it not being implemented. Any suggestions for yaml serialization?

error[E0277]: the trait bound `IndexMap<&str, std::option::Option<serde_json::Value>>: Serialize` is not satisfied
   --> src/main.rs:107:39
    |
107 |         let s = serde_yaml::to_string(&version_info)?;
    |                                       ^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `IndexMap<&str, std::option::Option<serde_json::Value>>`
    | 
   ::: /Users/jeffhykin/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_yaml-0.8.17/src/ser.rs:854:8
    |
854 |     T: ser::Serialize,
    |        -------------- required by this bound in `serde_yaml::to_string`
@cuviper
Copy link
Member

cuviper commented Apr 26, 2021

@jeff-hykin
Copy link
Author

Nope, I'll try that. And if there's an enable-all-features option I'll probably switch to that as well. I'll post on here once I get back into the codebase

Thanks!

@bluss bluss added the question label May 22, 2021
@bluss
Copy link
Member

bluss commented May 22, 2021

Thanks both. Using the required feature should be enough, feel free to open an issue if it doesn't work with that. 🙂

@bluss bluss closed this as completed May 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants