diff --git a/src/app.rs b/src/app.rs index e4da3ae..e44feaf 100644 --- a/src/app.rs +++ b/src/app.rs @@ -51,8 +51,8 @@ pub struct App { pub app_id: u32, /// The name of the installation directory of this Steam app e.g. `"GarrysMod"` /// - /// If you're trying to get the app's installation directory then take a look at - /// [`Library::resolve_app_dir()`][crate::Library::resolve_app_dir] + /// If you're trying to get the app's installation directory then take a look at + /// [`Library::resolve_app_dir()`][crate::Library::resolve_app_dir] #[serde(rename = "installdir")] pub install_dir: String, /// The store name of the Steam app diff --git a/src/lib.rs b/src/lib.rs index 7528003..448f6d4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -174,15 +174,15 @@ impl SteamDir { /// # Example /// ``` /// # let temp_steam_dir = steamlocate::tests::helpers::expect_test_env(); - /// # let steam_dir = temp_steam_dir.steam_dir(); - /// # /* - /// let steam_dir = SteamDir::locate()?; - /// # */ - /// const WARFRAME: u32 = 230_410; + /// # let steam_dir = temp_steam_dir.steam_dir(); + /// # /* + /// let steam_dir = SteamDir::locate()?; + /// # */ + /// const WARFRAME: u32 = 230_410; /// let (warframe, library) = steam_dir.find_app(WARFRAME)?.unwrap(); /// assert_eq!(warframe.app_id, WARFRAME); - /// assert!(library.app_ids().contains(&warframe.app_id)); - /// # Ok::<_, steamlocate::tests::TestError>(()) + /// assert!(library.app_ids().contains(&warframe.app_id)); + /// # Ok::<_, steamlocate::tests::TestError>(()) /// ``` pub fn find_app(&self, app_id: u32) -> Result> { // Search for the `app_id` in each library @@ -190,7 +190,10 @@ impl SteamDir { Err(e) => Err(e), Ok(libraries) => libraries .filter_map(|library| library.ok()) - .find_map(|lib| lib.app(app_id).map(|maybe_app| maybe_app.map(|app| (app, lib)))) + .find_map(|lib| { + lib.app(app_id) + .map(|maybe_app| maybe_app.map(|app| (app, lib))) + }) .transpose(), } } @@ -215,7 +218,7 @@ impl SteamDir { shortcut::Iter::new(&self.path) } - // TODO: rename to `from_dir()` and make consitent with similar constructors on other structs + // TODO: rename to `from_dir()` and make consitent with similar constructors on other structs pub fn from_steam_dir(path: &Path) -> Result { if !path.is_dir() { return Err(Error::validation(ValidationError::missing_dir())); diff --git a/src/library.rs b/src/library.rs index 2595efb..8db1f1a 100644 --- a/src/library.rs +++ b/src/library.rs @@ -154,24 +154,24 @@ impl Library { app::Iter::new(self) } - /// Resolves the theoretical installation directory for the given `app` - /// - /// This is an unvalidated path, so it's up to you to call this with an `app` that's in this - /// library - /// - /// # Example - /// - /// ``` - /// # use std::path::Path; - /// # let temp_steam_dir = steamlocate::tests::helpers::expect_test_env(); - /// # let steam_dir = temp_steam_dir.steam_dir(); - /// const GRAVEYARD_KEEPER: u32 = 599_140; - /// let (graveyard_keeper, library) = steam_dir.find_app(GRAVEYARD_KEEPER)?.unwrap(); - /// let app_dir = library.resolve_app_dir(&graveyard_keeper); - /// let expected_rel_path = Path::new("steamapps").join("common").join("Graveyard Keeper"); - /// assert!(app_dir.ends_with(expected_rel_path)); - /// # Ok::<_, steamlocate::tests::TestError>(()) - /// ``` + /// Resolves the theoretical installation directory for the given `app` + /// + /// This is an unvalidated path, so it's up to you to call this with an `app` that's in this + /// library + /// + /// # Example + /// + /// ``` + /// # use std::path::Path; + /// # let temp_steam_dir = steamlocate::tests::helpers::expect_test_env(); + /// # let steam_dir = temp_steam_dir.steam_dir(); + /// const GRAVEYARD_KEEPER: u32 = 599_140; + /// let (graveyard_keeper, library) = steam_dir.find_app(GRAVEYARD_KEEPER)?.unwrap(); + /// let app_dir = library.resolve_app_dir(&graveyard_keeper); + /// let expected_rel_path = Path::new("steamapps").join("common").join("Graveyard Keeper"); + /// assert!(app_dir.ends_with(expected_rel_path)); + /// # Ok::<_, steamlocate::tests::TestError>(()) + /// ``` pub fn resolve_app_dir(&self, app: &App) -> PathBuf { self.path .join("steamapps") diff --git a/src/tests/helpers.rs b/src/tests/helpers.rs index b496230..a2eb940 100644 --- a/src/tests/helpers.rs +++ b/src/tests/helpers.rs @@ -19,7 +19,7 @@ use serde::Serialize; pub fn expect_test_env() -> TempSteamDir { TempSteamDir::builder() .app(SampleApp::GarrysMod.into()) - .app(SampleApp::Warframe.into()) + .app(SampleApp::Warframe.into()) .library(SampleApp::GraveyardKeeper.try_into().unwrap()) .finish() .unwrap() @@ -258,7 +258,7 @@ impl AppFile { pub enum SampleApp { GarrysMod, GraveyardKeeper, - Warframe, + Warframe, } impl SampleApp { @@ -286,11 +286,11 @@ impl SampleApp { "Graveyard Keeper", include_str!("../../tests/assets/appmanifest_599140.acf"), ), - Self::Warframe => ( - 230_410, - "Warframe", - include_str!("../../tests/assets/appmanifest_230410.acf"), - ), + Self::Warframe => ( + 230_410, + "Warframe", + include_str!("../../tests/assets/appmanifest_230410.acf"), + ), } } } @@ -304,7 +304,10 @@ mod test { fn sanity() -> TestResult { let tmp_steam_dir = TempSteamDir::try_from(SampleApp::GarrysMod)?; let steam_dir = tmp_steam_dir.steam_dir(); - assert!(steam_dir.find_app(SampleApp::GarrysMod.id()).unwrap().is_some()); + assert!(steam_dir + .find_app(SampleApp::GarrysMod.id()) + .unwrap() + .is_some()); Ok(()) }