From d229aee52994fbf54d8034c4c6a16d01b43c3e91 Mon Sep 17 00:00:00 2001 From: Kornel Date: Fri, 1 Sep 2023 14:08:41 +0100 Subject: [PATCH] Compact debug for Feature --- src/features.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/features.rs b/src/features.rs index a85e0792..5e6fa65a 100644 --- a/src/features.rs +++ b/src/features.rs @@ -1,6 +1,6 @@ use std::{ collections::{BTreeMap, BTreeSet}, - slice, + fmt, slice, }; use crate::{manifest::Manifest, metadata::Metadata, PackageId}; @@ -87,7 +87,6 @@ impl Features { } /// The representation of Cargo feature. -#[derive(Debug)] pub(crate) enum Feature { /// A feature of the current crate. Normal { @@ -110,6 +109,20 @@ pub(crate) enum Feature { }, } +impl fmt::Debug for Feature { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + use fmt::Write; + match self { + Self::Normal { name } | Self::Path { name, .. } => f.write_str(name), + Self::Group { name, .. } => { + f.write_char('[')?; + f.write_str(name)?; + f.write_char(']') + } + } + } +} + impl Feature { pub(crate) fn group(group: impl IntoIterator>) -> Self { let list: Vec<_> = group.into_iter().map(Into::into).collect();