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

Introduce a trait for token-aware formatting #143

Merged
merged 1 commit into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fmt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod to_fmt;
mod to_value;
mod to_write;

pub use self::{to_fmt::*, to_value::*, to_write::*};
pub use self::{to_fmt::*, to_value::*, to_write::*, writer::*};

#[cfg(feature = "alloc")]
mod to_string;
Expand Down
9 changes: 8 additions & 1 deletion fmt/src/to_write.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::writer::{GenericWriter, Writer};
use crate::writer::{GenericWriter, TokenWrite, Writer};
use core::fmt::{self, Write};

/**
Expand All @@ -8,3 +8,10 @@ pub fn stream_to_write(fmt: impl Write, v: impl sval::Value) -> fmt::Result {
v.stream(&mut Writer::new(GenericWriter(fmt)))
.map_err(|_| fmt::Error)
}

/**
Format a value into an underlying token-aware formatter.
*/
pub fn stream_to_token_write(fmt: impl TokenWrite, v: impl sval::Value) -> fmt::Result {
v.stream(&mut Writer::new(fmt)).map_err(|_| fmt::Error)
}
Loading