From fe61a25cfdfae0b6b553b7d733b68692d4fc96cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Wed, 24 Jul 2024 16:07:59 +0200 Subject: [PATCH] xso: improve macro for FromXmlText/AsXmlText Now it's not limited to a single feature gate per type (or even just feature gates: it should now also be possible to add constraints based on OS, for example) anymore. --- xso/src/text.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/xso/src/text.rs b/xso/src/text.rs index 8e9bae2d..00a6b9f2 100644 --- a/xso/src/text.rs +++ b/xso/src/text.rs @@ -15,17 +15,13 @@ use crate::{error::Error, AsXmlText, FromXmlText}; #[cfg(feature = "base64")] use base64::engine::{general_purpose::STANDARD as StandardBase64Engine, Engine as _}; -#[cfg(feature = "jid")] -use jid; -#[cfg(feature = "uuid")] -use uuid; macro_rules! convert_via_fromstr_and_display { - ($($(#[cfg(feature = $feature:literal)])?$t:ty,)+) => { + ($($(#[cfg $cfg:tt])?$t:ty,)+) => { $( $( - #[cfg(feature = $feature)] - #[cfg_attr(docsrs, doc(cfg(feature = $feature)))] + #[cfg $cfg] + #[cfg_attr(docsrs, doc(cfg $cfg))] )? impl FromXmlText for $t { #[doc = concat!("Parse [`", stringify!($t), "`] from XML text via [`FromStr`][`core::str::FromStr`].")] @@ -35,8 +31,8 @@ macro_rules! convert_via_fromstr_and_display { } $( - #[cfg(feature = $feature)] - #[cfg_attr(docsrs, doc(cfg(feature = $feature)))] + #[cfg $cfg] + #[cfg_attr(docsrs, doc(cfg $cfg))] )? impl AsXmlText for $t { #[doc = concat!("Convert [`", stringify!($t), "`] to XML text via [`Display`][`core::fmt::Display`].\n\nThis implementation never fails.")]