Skip to content

Commit

Permalink
Merge #206
Browse files Browse the repository at this point in the history
206: feat: port `ser::Serializer` to `io::Write` r=kvark a=Plecra

Makes the `Serializer` struct generic over `io::Write`, allowing it to be used with more types (and less allocation). As a side-effect, the trailing commas are also removed from the output.

This was a quick implementation, written in response to compiler messages, so it could probably do with some cleaning up. It might be a good time to approach #175 

Closes #202 

## TODO

- [ ] Update docs


Co-authored-by: Marli Frost <marli@frost.red>
  • Loading branch information
bors[bot] and Plecra committed Apr 27, 2020
2 parents 92c1d5d + 5b42d62 commit 7aed839
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 216 deletions.
9 changes: 5 additions & 4 deletions src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ pub use crate::parse::Position;
use serde::de::{self, DeserializeSeed, Deserializer as SerdeError, Visitor};
use std::{borrow::Cow, io, str};

use self::id::IdDeserializer;
use self::tag::TagDeserializer;
use crate::extensions::Extensions;
use crate::parse::{AnyNum, Bytes, ParsedStr};
use self::{id::IdDeserializer, tag::TagDeserializer};
use crate::{
extensions::Extensions,
parse::{AnyNum, Bytes, ParsedStr},
};

mod error;
mod id;
Expand Down
6 changes: 4 additions & 2 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ use std::{
str::{from_utf8, from_utf8_unchecked, FromStr},
};

use crate::de::{Error, ParseError, Result};
use crate::extensions::Extensions;
use crate::{
de::{Error, ParseError, Result},
extensions::Extensions,
};

const DIGITS: &[u8] = b"0123456789ABCDEFabcdef_";
const FLOAT_CHARS: &[u8] = b"0123456789.+-eE";
Expand Down
Loading

0 comments on commit 7aed839

Please sign in to comment.