From 10297d29bbe46f3cffee21bfb7ddef2801a1f358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Mon, 17 Oct 2022 13:55:02 +0200 Subject: [PATCH] Make Scope use a BTreeSet internally --- crates/oauth2-types/src/scope.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/oauth2-types/src/scope.rs b/crates/oauth2-types/src/scope.rs index 7c6aa6e8..294f2dee 100644 --- a/crates/oauth2-types/src/scope.rs +++ b/crates/oauth2-types/src/scope.rs @@ -14,7 +14,7 @@ #![allow(clippy::module_name_repetitions)] -use std::{borrow::Cow, collections::HashSet, iter::FromIterator, ops::Deref, str::FromStr}; +use std::{borrow::Cow, collections::BTreeSet, iter::FromIterator, ops::Deref, str::FromStr}; use itertools::Itertools; use serde::{Deserialize, Serialize}; @@ -82,10 +82,10 @@ impl ToString for ScopeToken { } #[derive(Debug, Clone, PartialEq, Eq)] -pub struct Scope(HashSet); +pub struct Scope(BTreeSet); impl std::ops::Deref for Scope { - type Target = HashSet; + type Target = BTreeSet; fn deref(&self) -> &Self::Target { &self.0 @@ -100,7 +100,7 @@ impl FromStr for Scope { // https://datatracker.ietf.org/doc/html/rfc6749#appendix-A.4 // // scope = scope-token *( SP scope-token ) - let scopes: Result, InvalidScope> = + let scopes: Result, InvalidScope> = s.split(' ').map(ScopeToken::from_str).collect(); Ok(Self(scopes?)) @@ -160,7 +160,7 @@ impl<'de> Deserialize<'de> for Scope { impl FromIterator for Scope { fn from_iter>(iter: T) -> Self { - Self(HashSet::from_iter(iter)) + Self(BTreeSet::from_iter(iter)) } }