Skip to content

Commit

Permalink
serde-with-extras: impl Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
tinybeachthor committed Dec 16, 2024
1 parent 757a42b commit e1a9ef0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion serde-with-extras/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use std::fmt::Debug;

use indexmap::IndexMap;
use serde::{ser::SerializeTupleStruct, Serialize};

// re-export indexmap macro to construct attributes
pub use indexmap::indexmap as extras;

pub const SERDE_EXTRAS_WELLKNOWN_NAME: &str = "__SERDE_EXTRAS_/_EXTRAS";
pub const SERDE_EXTRAS_WELLKNOWN_NAME: &str = "__SERDE_EXTRAS__EXTRAS";

pub const EXTRAS_COMMENT_BEFORE: &str = "comment";
pub const EXTRAS_COMMENT_AFTER: &str = "comment-after";
Expand Down Expand Up @@ -33,6 +35,15 @@ impl<T: Serialize> Serialize for Extras<T> {
}
}

impl<T: Debug> Debug for Extras<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Extras")
.field("inner", &self.inner)
.field("extras", &self.extras)
.finish()
}
}

impl<T: Clone> Clone for Extras<T> {
fn clone(&self) -> Self {
Self {
Expand Down

0 comments on commit e1a9ef0

Please sign in to comment.