Skip to content

Commit

Permalink
Merge pull request #228 from paolobarbolini/drop-itertools
Browse files Browse the repository at this point in the history
Drop itertools dependency
  • Loading branch information
dermesser authored Jun 11, 2024
2 parents a2ebecd + e5af4ef commit a55609d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ hyper = "1"
hyper-util = { version = "0.1.5", features = ["client-legacy", "server-auto", "http1", "http2", "server-graceful"] }
hyper-rustls = { version = "0.27", optional = true, default-features = false, features = ["http1", "http2", "rustls-native-certs", "ring"] }
hyper-tls = { version = "0.6.0", optional = true }
itertools = "0.13"
log = "0.4"
percent-encoding = "2"
rustls = { version = "^0.23", optional = true, features = ["ring"] }
Expand Down
26 changes: 10 additions & 16 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
pub use crate::types::TokenInfo;

use futures::lock::Mutex;
use itertools::Itertools;
use std::collections::HashMap;
use std::io;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -138,20 +137,15 @@ impl Storage {
Storage::Memory { tokens } => Ok(tokens.lock().await.set(scopes, token)?),
Storage::Disk(disk_storage) => Ok(disk_storage.set(scopes, token).await?),
Storage::Custom(custom_storage) => {
let str_scopes: Vec<_> = scopes
let mut str_scopes = scopes
.scopes
.iter()
.map(|scope| scope.as_ref())
.sorted()
.unique()
.collect();

custom_storage
.set(
&str_scopes[..], // TODO: sorted, unique
token,
)
.await
.collect::<Vec<_>>();
str_scopes.sort_unstable();
str_scopes.dedup();

custom_storage.set(&str_scopes[..], token).await
}
}
}
Expand All @@ -164,13 +158,13 @@ impl Storage {
Storage::Memory { tokens } => tokens.lock().await.get(scopes),
Storage::Disk(disk_storage) => disk_storage.get(scopes).await,
Storage::Custom(custom_storage) => {
let str_scopes: Vec<_> = scopes
let mut str_scopes = scopes
.scopes
.iter()
.map(|scope| scope.as_ref())
.sorted()
.unique()
.collect();
.collect::<Vec<_>>();
str_scopes.sort_unstable();
str_scopes.dedup();

custom_storage.get(&str_scopes[..]).await
}
Expand Down

0 comments on commit a55609d

Please sign in to comment.