Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/cfg/src/lib.rs')
| -rw-r--r-- | crates/cfg/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/cfg/src/lib.rs b/crates/cfg/src/lib.rs index 08545b6851..26860fb932 100644 --- a/crates/cfg/src/lib.rs +++ b/crates/cfg/src/lib.rs @@ -104,6 +104,12 @@ impl CfgOptions { _ => None, }) } + + pub fn to_hashable(&self) -> HashableCfgOptions { + let mut enabled = self.enabled.iter().cloned().collect::<Box<[_]>>(); + enabled.sort_unstable(); + HashableCfgOptions { _enabled: enabled } + } } impl Extend<CfgAtom> for CfgOptions { @@ -256,3 +262,9 @@ impl fmt::Display for InactiveReason { Ok(()) } } + +/// A `CfgOptions` that implements `Hash`, for the sake of hashing only. +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct HashableCfgOptions { + _enabled: Box<[CfgAtom]>, +} |