diff options
| author | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2024-10-04 11:34:19 +0200 |
|---|---|---|
| committer | Sebastian Holmin <sebastian.holmin@mullvad.net> | 2024-10-07 15:40:29 +0200 |
| commit | 4f586f8432372e8e1b6089cd56dc5cf36236f2b5 (patch) | |
| tree | bceabdc2e96404324b9886a53939eccd0a9ff529 | |
| parent | 5d69b1dbd8c27e5e5c040bdc7050dae474f299c3 (diff) | |
| download | mullvadvpn-4f586f8432372e8e1b6089cd56dc5cf36236f2b5.tar.xz mullvadvpn-4f586f8432372e8e1b6089cd56dc5cf36236f2b5.zip | |
Sort feature indicators in alphabetical order in debug fmt
| -rw-r--r-- | mullvad-types/src/features.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/mullvad-types/src/features.rs b/mullvad-types/src/features.rs index 6f4ea1e9cc..cb6bb23f98 100644 --- a/mullvad-types/src/features.rs +++ b/mullvad-types/src/features.rs @@ -1,4 +1,7 @@ -use std::{collections::HashSet, fmt::Display}; +use std::{ + collections::HashSet, + fmt::{Debug, Display}, +}; use crate::{ relay_constraints::RelaySettings, @@ -11,9 +14,20 @@ use talpid_types::net::{ObfuscationType, TunnelEndpoint, TunnelType}; /// what is affecting their connection at any given time. /// /// Note that the feature indicators are not ordered. -#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Default, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct FeatureIndicators(HashSet<FeatureIndicator>); +impl Debug for FeatureIndicators { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut indicators: Vec<&str> = self.0.iter().map(|feature| feature.to_str()).collect(); + // Sort the features alphabetically (Just to have some order, arbitrarily chosen) + indicators.sort(); + f.debug_tuple("FeatureIndicators") + .field(&indicators) + .finish() + } +} + impl FeatureIndicators { pub fn is_empty(&self) -> bool { self.0.is_empty() |
