Skip to content

Commit

Permalink
Merge pull request #185 from escritorio-gustavo/quiet-serde
Browse files Browse the repository at this point in the history
Add `quiet-serde` feature flag
  • Loading branch information
NyxCode authored Jan 11, 2024
2 parents fdeb5a0 + 37642a3 commit 9657feb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ repository = "https://github.com/Aleph-Alpha/ts-rs"

[features]
serde-compat = ["termcolor"]
quiet-serde = []

[lib]
proc-macro = true
Expand Down
4 changes: 4 additions & 0 deletions macros/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ pub fn parse_serde_attrs<'a, A: TryFrom<&'a Attribute, Error = Error>>(
.flat_map(|attr| match A::try_from(attr) {
Ok(attr) => Some(attr),
Err(_) => {
#[cfg(not(feature = "quiet-serde"))]
use quote::ToTokens;

#[cfg(not(feature = "quiet-serde"))]
warning::print_warning(
"failed to parse serde attribute",
format!("{}", attr.to_token_stream()),
Expand All @@ -121,6 +124,7 @@ mod warning {

// Sadly, it is impossible to raise a warning in a proc macro.
// This function prints a message which looks like a compiler warning.
#[allow(unused)]
pub fn print_warning(
title: impl Display,
content: impl Display,
Expand Down
1 change: 1 addition & 0 deletions ts-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ default = ["serde-compat"]
indexmap-impl = ["indexmap"]
ordered-float-impl = ["ordered-float"]
heapless-impl = ["heapless"]
quiet-serde = ["ts-rs-macros/quiet-serde"]

[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }
Expand Down

0 comments on commit 9657feb

Please sign in to comment.