Skip to content

Commit f4de9eb

Browse files
authored
style: rustfmt (#45)
Signed-off-by: AltF2 <contact@altf2.dev>
1 parent 14939e5 commit f4de9eb

File tree

21 files changed

+1040
-482
lines changed

21 files changed

+1040
-482
lines changed

src-tauri/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn main() {
2-
tauri_build::build()
2+
tauri_build::build()
33
}

src-tauri/src/common/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::fs;
21
use serde::Deserialize;
2+
use std::fs;
33

44
use super::errors::IncResult;
55

@@ -32,4 +32,4 @@ pub struct ConfigRange {
3232
pub fn load_config() -> IncResult<Config> {
3333
let config_contents = fs::read_to_string(CONFIG_PATH)?;
3434
Ok(toml::from_str(config_contents.as_str())?)
35-
}
35+
}

src-tauri/src/common/errors.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub enum Error {
66
Toml(#[from] toml::de::Error),
77
#[error(transparent)]
88
SerdeJson(#[from] serde_json::Error),
9-
9+
1010
#[error("{0}")]
1111
Warning(String),
1212

@@ -21,16 +21,16 @@ pub enum Error {
2121

2222
#[error("An unexpected issue occured.")]
2323
DangerUnexpected,
24-
24+
2525
#[error("An unexpected issue occured.")]
2626
FatalUnexpected,
2727
}
2828

2929
impl serde::Serialize for Error {
3030
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
31-
where
32-
S: serde::Serializer {
33-
31+
where
32+
S: serde::Serializer,
33+
{
3434
use serde::ser::SerializeStruct;
3535

3636
let mut state = serializer.serialize_struct("Error", 2)?;
@@ -59,4 +59,4 @@ pub enum Severity {
5959
Warning,
6060
Danger,
6161
Fatal,
62-
}
62+
}

src-tauri/src/common/filesystem.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ const DATA_PATH: &str = "./data";
44
const SAVES_PATH: &str = "./data/saves";
55

66
fn check_data_directories() -> IncResult<()> {
7-
if !std::path::Path::new(DATA_PATH).exists() {
8-
std::fs::create_dir(DATA_PATH)?;
9-
std::fs::create_dir(SAVES_PATH)?;
7+
if !std::path::Path::new(DATA_PATH).exists() {
8+
std::fs::create_dir(DATA_PATH)?;
9+
std::fs::create_dir(SAVES_PATH)?;
1010

11-
return Ok(());
12-
}
11+
return Ok(());
12+
}
1313

14-
if !std::path::Path::new(SAVES_PATH).exists() {
15-
std::fs::create_dir(SAVES_PATH)?;
16-
}
14+
if !std::path::Path::new(SAVES_PATH).exists() {
15+
std::fs::create_dir(SAVES_PATH)?;
16+
}
1717

18-
Ok(())
18+
Ok(())
1919
}
2020

2121
// pub fn create_save(name: String) -> IncResult<()> {
@@ -25,6 +25,6 @@ fn check_data_directories() -> IncResult<()> {
2525

2626
#[tauri::command]
2727
pub fn check_save_exists(name: String) -> IncResult<bool> {
28-
check_data_directories()?;
29-
Ok(std::path::Path::new(&format!("{}/{}", SAVES_PATH, name)).exists())
30-
}
28+
check_data_directories()?;
29+
Ok(std::path::Path::new(&format!("{}/{}", SAVES_PATH, name)).exists())
30+
}

src-tauri/src/common/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
pub mod filesystem;
21
pub mod config;
3-
pub mod util;
2+
pub mod errors;
3+
pub mod filesystem;
44
pub mod payloads;
5-
pub mod errors;
5+
pub mod util;

src-tauri/src/common/payloads.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ pub struct PayloadNewDay {
88
#[derive(Clone, Serialize)]
99
pub struct NewGame {
1010
pub population: i32,
11-
}
11+
}

src-tauri/src/common/util.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use rand::Rng;
22
use serde::{Deserialize, Serialize};
3-
use std::{collections::HashMap, ops::{Index, IndexMut}};
3+
use std::{
4+
collections::HashMap,
5+
ops::{Index, IndexMut},
6+
};
47

5-
use crate::{game::structs::{HealthcareGroup, HealthcareState}};
8+
use crate::game::structs::{HealthcareGroup, HealthcareState};
69

710
#[macro_export]
811
macro_rules! percentage_of {
@@ -150,7 +153,12 @@ impl Date {
150153
}
151154

152155
pub fn get_date_string(&self) -> String {
153-
format!("{}/{}/{}", zerofy(self.day, 2), zerofy(self.month, 2), zerofy(self.year, 4))
156+
format!(
157+
"{}/{}/{}",
158+
zerofy(self.day, 2),
159+
zerofy(self.month, 2),
160+
zerofy(self.year, 4)
161+
)
154162
}
155163
}
156164

@@ -223,7 +231,9 @@ impl<T: Default + Clone> SlotArray<T> {
223231
}
224232
}
225233

226-
pub fn len(&self) -> usize { self.array.len() }
234+
pub fn len(&self) -> usize {
235+
self.array.len()
236+
}
227237
}
228238

229239
impl<T> Index<usize> for SlotArray<T> {
@@ -240,7 +250,7 @@ impl<T> IndexMut<usize> for SlotArray<T> {
240250
}
241251

242252
pub fn generate_unemployed_salary() -> i32 {
243-
rand::thread_rng().gen_range(300..=1100)
253+
rand::thread_rng().gen_range(300..=1100)
244254
}
245255

246256
pub fn get_healthcare_group(age: i32, healthcare: &mut HealthcareState) -> &mut HealthcareGroup {
@@ -249,4 +259,4 @@ pub fn get_healthcare_group(age: i32, healthcare: &mut HealthcareState) -> &mut
249259
age if age <= 65 => &mut healthcare.adultcare,
250260
_ => &mut healthcare.eldercare,
251261
}
252-
}
262+
}

0 commit comments

Comments
 (0)