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:
Jon Seager 2026-02-13 15:10:48 +00:00
parent 766ac1432d
commit 31cb7c6c71
No known key found for this signature in database
2 changed files with 3 additions and 13 deletions

View file

@ -1,5 +1,3 @@
use std::net::SocketAddr;
use anyhow::{Context, Result, anyhow}; use anyhow::{Context, Result, anyhow};
use clap::{Args, Subcommand}; use clap::{Args, Subcommand};
use tokio::net::TcpListener; 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 (tx, rx) = oneshot::channel::<String>();
let expected_state = state.clone(); let expected_state = state.clone();
let server = tokio::spawn(run_callback_server( let server = tokio::spawn(run_callback_server(listener, expected_state, tx));
listener,
local_addr,
expected_state,
tx,
));
// Wait for the token with a timeout // Wait for the token with a timeout
let token = tokio::select! { let token = tokio::select! {
@ -110,7 +103,6 @@ pub async fn create_token(client: &BrewlogClient, cmd: CreateTokenCommand) -> Re
async fn run_callback_server( async fn run_callback_server(
listener: TcpListener, listener: TcpListener,
_addr: SocketAddr,
expected_state: String, expected_state: String,
tx: oneshot::Sender<String>, tx: oneshot::Sender<String>,
) { ) {

View file

@ -151,11 +151,9 @@ impl From<NearbyCafeResult> for NearbyCafeView {
} else { } else {
format!("{:.1} km", f64::from(cafe.distance_meters) / 1000.0) format!("{:.1} km", f64::from(cafe.distance_meters) / 1000.0)
}; };
let location = [&cafe.city, &cafe.country] let location = [cafe.city.as_str(), cafe.country.as_str()]
.iter() .into_iter()
.filter(|s| !s.is_empty()) .filter(|s| !s.is_empty())
.copied()
.cloned()
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(", "); .join(", ");
Self { Self {