Skip to content

Commit

Permalink
Fixing more and more
Browse files Browse the repository at this point in the history
  • Loading branch information
fasterthanlime committed Nov 4, 2024
1 parent efb79a1 commit bec8c92
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion merde/examples/ahash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() {

println!("h: {:#?}", h);

let serialized = json::to_string(&h);
let serialized = json::to_string(&h).unwrap();
println!("serialized: {}", serialized);

let deserialized: HashMap<String, String> = json::from_str(&serialized).unwrap();
Expand Down
7 changes: 7 additions & 0 deletions merde/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ macro_rules! impl_serialize {
};
}

#[doc(hidden)]
#[macro_export]
#[cfg(not(feature = "core"))]
macro_rules! impl_serialize {
($($rest:tt)*) => {};
}

#[doc(hidden)]
#[macro_export]
macro_rules! impl_trait {
Expand Down
6 changes: 4 additions & 2 deletions merde_json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use merde_core::{
Serializer,
};

use std::{collections::VecDeque, future::Future, io::Write, pin::Pin};
use std::{collections::VecDeque, future::Future, io::Write};

/// Something the JSON serializer can write to
pub trait JsonSerializerWriter {
Expand Down Expand Up @@ -94,6 +94,7 @@ where
if matches!(ev, merde_core::Event::ArrayEnd) {
self.w.extend_from_slice(b"]").await?;
self.stack.pop_back();
return Ok(());
} else if *first {
*first = false
} else {
Expand All @@ -104,6 +105,7 @@ where
if matches!(ev, merde_core::Event::MapEnd) {
self.w.extend_from_slice(b"}").await?;
self.stack.pop_back();
return Ok(());
} else {
if !*first {
self.w.extend_from_slice(b",").await?;
Expand Down Expand Up @@ -209,7 +211,7 @@ impl<'w> JsonSerializer<SyncWriteWrapper<'w>> {
impl<'w> JsonSerializer<tokio_io::AsyncWriteWrapper<'w>> {
/// Makes a json serializer that writes to a tokio::io::AsyncWrite
pub fn from_tokio_writer<SW: tokio::io::AsyncWrite + 'w>(
w: Pin<&'w mut SW>,
w: std::pin::Pin<&'w mut SW>,
) -> JsonSerializer<tokio_io::AsyncWriteWrapper<'w>> {
JsonSerializer::new(tokio_io::AsyncWriteWrapper(w))
}
Expand Down

0 comments on commit bec8c92

Please sign in to comment.