Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Add a Serializer #186

Merged
merged 5 commits into from Feb 2, 2021
Merged

Add a Serializer #186

merged 5 commits into from Feb 2, 2021

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Feb 2, 2021

use anyhow::Result;
use serde::Serialize;
use std::collections::BTreeMap;

fn main() -> Result<()> {
    let mut buffer = Vec::new();
    let mut ser = serde_yaml::Serializer::new(&mut buffer);

    let mut object = BTreeMap::new();
    object.insert("k", 107);
    object.serialize(&mut ser)?;

    assert_eq!(buffer, b"---\nk: 107\n");
    Ok(())
}

Closes #44.

    error: this argument is passed by value, but not consumed in the function body
      --> src/ser.rs:33:30
       |
    33 |     fn write(&mut self, doc: Yaml) -> Result<()> {
       |                              ^^^^ help: consider taking a reference instead: `&Yaml`
       |
       = note: `-D clippy::needless-pass-by-value` implied by `-D clippy::pedantic`
       = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_pass_by_value
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose the Serializer and Deserializer types
1 participant