Skip to content

Commit

Permalink
Compact debug for Feature
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski authored and taiki-e committed Sep 1, 2023
1 parent 09913d6 commit d229aee
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/features.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::{BTreeMap, BTreeSet},
slice,
fmt, slice,
};

use crate::{manifest::Manifest, metadata::Metadata, PackageId};
Expand Down Expand Up @@ -87,7 +87,6 @@ impl Features {
}

/// The representation of Cargo feature.
#[derive(Debug)]
pub(crate) enum Feature {
/// A feature of the current crate.
Normal {
Expand All @@ -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<Item = impl Into<String>>) -> Self {
let list: Vec<_> = group.into_iter().map(Into::into).collect();
Expand Down

0 comments on commit d229aee

Please sign in to comment.