refactor: simplify NearbyCafeView iterator chain and remove unused _addr parameter
- Replace .iter().copied().cloned() with .into_iter() on str slices in NearbyCafeView::from - Remove unused _addr: SocketAddr parameter from run_callback_server and its call site in tokens.rs
This commit is contained in:
parent
766ac1432d
commit
31cb7c6c71
2 changed files with 3 additions and 13 deletions
|
|
@ -1,5 +1,3 @@
|
|||
use std::net::SocketAddr;
|
||||
|
||||
use anyhow::{Context, Result, anyhow};
|
||||
use clap::{Args, Subcommand};
|
||||
use tokio::net::TcpListener;
|
||||
|
|
@ -78,12 +76,7 @@ pub async fn create_token(client: &BrewlogClient, cmd: CreateTokenCommand) -> Re
|
|||
let (tx, rx) = oneshot::channel::<String>();
|
||||
let expected_state = state.clone();
|
||||
|
||||
let server = tokio::spawn(run_callback_server(
|
||||
listener,
|
||||
local_addr,
|
||||
expected_state,
|
||||
tx,
|
||||
));
|
||||
let server = tokio::spawn(run_callback_server(listener, expected_state, tx));
|
||||
|
||||
// Wait for the token with a timeout
|
||||
let token = tokio::select! {
|
||||
|
|
@ -110,7 +103,6 @@ pub async fn create_token(client: &BrewlogClient, cmd: CreateTokenCommand) -> Re
|
|||
|
||||
async fn run_callback_server(
|
||||
listener: TcpListener,
|
||||
_addr: SocketAddr,
|
||||
expected_state: String,
|
||||
tx: oneshot::Sender<String>,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -151,11 +151,9 @@ impl From<NearbyCafeResult> for NearbyCafeView {
|
|||
} else {
|
||||
format!("{:.1} km", f64::from(cafe.distance_meters) / 1000.0)
|
||||
};
|
||||
let location = [&cafe.city, &cafe.country]
|
||||
.iter()
|
||||
let location = [cafe.city.as_str(), cafe.country.as_str()]
|
||||
.into_iter()
|
||||
.filter(|s| !s.is_empty())
|
||||
.copied()
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
Self {
|
||||
|
|
|
|||
Loading…
Reference in a new issue