From 970d0f7451aa88514130831f1e1336dc8d6e04a0 Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Mon, 11 Dec 2023 21:16:29 -0500 Subject: [PATCH] cargo fmt --- .../src/runtime/api/user_settings.rs | 7 ++--- .../src/settings/gui.rs | 2 +- .../livesplit-auto-splitting/src/wasi_path.rs | 31 ++++++++++++++----- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/crates/livesplit-auto-splitting/src/runtime/api/user_settings.rs b/crates/livesplit-auto-splitting/src/runtime/api/user_settings.rs index c412cf78..ec28f389 100644 --- a/crates/livesplit-auto-splitting/src/runtime/api/user_settings.rs +++ b/crates/livesplit-auto-splitting/src/runtime/api/user_settings.rs @@ -136,15 +136,12 @@ pub fn bind(linker: &mut Linker>) -> Result<(), CreationErr let (memory, context) = memory_and_context(&mut caller); let key = get_str(memory, key_ptr, key_len)?.into(); let description = get_str(memory, description_ptr, description_len)?.into(); - let filter = - get_str(memory, filter_ptr, filter_len)?.into(); + let filter = get_str(memory, filter_ptr, filter_len)?.into(); Arc::make_mut(&mut context.settings_widgets).push(settings::Widget { key, description, tooltip: None, - kind: settings::WidgetKind::FileSelection { - filter, - }, + kind: settings::WidgetKind::FileSelection { filter }, }); Ok(()) } diff --git a/crates/livesplit-auto-splitting/src/settings/gui.rs b/crates/livesplit-auto-splitting/src/settings/gui.rs index f035388f..d17e77e9 100644 --- a/crates/livesplit-auto-splitting/src/settings/gui.rs +++ b/crates/livesplit-auto-splitting/src/settings/gui.rs @@ -48,7 +48,7 @@ pub enum WidgetKind { /// A filter on which files are selectable, /// for example `"*.txt"` for text files. filter: Arc, - } + }, } /// An option for a choice setting. diff --git a/crates/livesplit-auto-splitting/src/wasi_path.rs b/crates/livesplit-auto-splitting/src/wasi_path.rs index fc5135b3..94a52c0e 100644 --- a/crates/livesplit-auto-splitting/src/wasi_path.rs +++ b/crates/livesplit-auto-splitting/src/wasi_path.rs @@ -45,13 +45,17 @@ pub fn wasi_to_path(wasi_path_str: &str) -> Option { (2, Component::Normal(d)) if d.len() == 1 && d.to_ascii_lowercase() == d => { let disk = d.to_string_lossy().to_ascii_uppercase(); path.push(format!("{}{}{}", r"\\?\", disk, r":\")); - }, + } (2, Component::Normal(c)) if !path.has_root() => { - if let Some(root) = [r"/", r"\"].into_iter().map(PathBuf::from).find(|p| p.has_root()) { + if let Some(root) = [r"/", r"\"] + .into_iter() + .map(PathBuf::from) + .find(|p| p.has_root()) + { path.push(root); } path.push(c); - }, + } (i, Component::Normal(c)) if 2 <= i => path.push(c), _ => return None, } @@ -59,7 +63,6 @@ pub fn wasi_to_path(wasi_path_str: &str) -> Option { Some(path) } - #[cfg(test)] mod tests { use super::*; @@ -67,24 +70,36 @@ mod tests { #[cfg(windows)] #[test] fn test_windows_to_wasi() { - assert_eq!(path_to_wasi(Path::new(r"C:\foo\bar.exe")), Some(r"/mnt/c/foo/bar.exe".into())); + assert_eq!( + path_to_wasi(Path::new(r"C:\foo\bar.exe")), + Some(r"/mnt/c/foo/bar.exe".into()) + ); } #[cfg(windows)] #[test] fn test_wasi_to_windows() { - assert_eq!(wasi_to_path(r"/mnt/c/foo/bar.exe"), Some(r"C:\foo\bar.exe".into())); + assert_eq!( + wasi_to_path(r"/mnt/c/foo/bar.exe"), + Some(r"C:\foo\bar.exe".into()) + ); } #[cfg(not(windows))] #[test] fn test_non_windows_to_wasi() { - assert_eq!(path_to_wasi(Path::new(r"/foo/bar.exe")), Some(r"/mnt/foo/bar.exe".into())); + assert_eq!( + path_to_wasi(Path::new(r"/foo/bar.exe")), + Some(r"/mnt/foo/bar.exe".into()) + ); } #[cfg(not(windows))] #[test] fn test_wasi_to_non_windows() { - assert_eq!(wasi_to_path(r"/mnt/foo/bar.exe"), Some(r"/foo/bar.exe".into())); + assert_eq!( + wasi_to_path(r"/mnt/foo/bar.exe"), + Some(r"/foo/bar.exe".into()) + ); } }