style: format code for better readability in tests and function signatures
Some checks failed
CI / test (push) Failing after 4m59s
CI / clippy (push) Failing after 4m58s
CI / fmt (push) Successful in 23s

This commit is contained in:
2026-03-18 13:59:53 +01:00
parent 3d2bd5f9fe
commit 2e773cdeaf
4 changed files with 23 additions and 18 deletions

View File

@@ -167,10 +167,7 @@ mod tests {
#[test] #[test]
fn split_quoted_path() { fn split_quoted_path() {
assert_eq!( assert_eq!(shell_split(r#""My App" --flag"#), vec!["My App", "--flag"]);
shell_split(r#""My App" --flag"#),
vec!["My App", "--flag"]
);
} }
#[test] #[test]

View File

@@ -105,15 +105,14 @@ impl Plugin for ExternalPlugin {
} }
let result = match guard.as_mut() { let result = match guard.as_mut() {
Some(io) => tokio::time::timeout( Some(io) => {
std::time::Duration::from_secs(5), tokio::time::timeout(std::time::Duration::from_secs(5), do_search(io, query))
do_search(io, query), .await
) .unwrap_or_else(|_| {
.await tracing::warn!("plugin {} search timed out", self.name);
.unwrap_or_else(|_| { Err("timeout".into())
tracing::warn!("plugin {} search timed out", self.name); })
Err("timeout".into()) }
}),
None => unreachable!(), None => unreachable!(),
}; };

View File

@@ -57,7 +57,10 @@ impl FrecencyStore {
.as_secs(); .as_secs();
let json = { let json = {
let mut data = self.data.lock().unwrap(); let mut data = self.data.lock().unwrap();
let entry = data.entry(id.to_string()).or_insert(Entry { count: 0, last_used: 0 }); let entry = data.entry(id.to_string()).or_insert(Entry {
count: 0,
last_used: 0,
});
entry.count += 1; entry.count += 1;
entry.last_used = now; entry.last_used = now;
serde_json::to_string(&*data).ok() serde_json::to_string(&*data).ok()

View File

@@ -135,7 +135,10 @@ fn save_to_path(path: &Path, entries: &HashMap<String, CachedEntry>) {
} }
} }
fn build_entries(source: &impl DesktopEntrySource, _frecency: &Arc<FrecencyStore>) -> HashMap<String, CachedEntry> { fn build_entries(
source: &impl DesktopEntrySource,
_frecency: &Arc<FrecencyStore>,
) -> HashMap<String, CachedEntry> {
source source
.entries() .entries()
.into_iter() .into_iter()
@@ -209,7 +212,10 @@ impl AppsPlugin {
} }
#[cfg(test)] #[cfg(test)]
fn new_for_test(source: impl DesktopEntrySource + 'static, frecency: Arc<FrecencyStore>) -> Self { fn new_for_test(
source: impl DesktopEntrySource + 'static,
frecency: Arc<FrecencyStore>,
) -> Self {
Self::new_impl(source, frecency, None) Self::new_impl(source, frecency, None)
} }
} }
@@ -498,8 +504,8 @@ mod tests {
#[test] #[test]
fn apps_loads_from_cache_when_source_is_empty() { fn apps_loads_from_cache_when_source_is_empty() {
let frecency = ephemeral_frecency(); let frecency = ephemeral_frecency();
let cache_file = std::env::temp_dir() let cache_file =
.join(format!("k-launcher-test-{}.bin", std::process::id())); std::env::temp_dir().join(format!("k-launcher-test-{}.bin", std::process::id()));
// Build entries from a real source and save to temp path // Build entries from a real source and save to temp path
let source = MockSource::with(vec![("Firefox", "firefox")]); let source = MockSource::with(vec![("Firefox", "firefox")]);