Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
PabstMirror committed Sep 12, 2024
1 parent 9c6a70b commit 3417b81
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
4 changes: 3 additions & 1 deletion extension/src/ballistics/drag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ impl FromArma for DragFunction {
"6" => Ok(Self::G6),
"7" => Ok(Self::G7),
"8" => Ok(Self::G8),
_ => Err(FromArmaError::InvalidValue(format!("Unknown drag function: {s}"))),
_ => Err(FromArmaError::InvalidValue(format!(
"Unknown drag function: {s}"
))),
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion extension/src/common/types/height.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ impl Height {

impl FromArma for Height {
fn from_arma(value: String) -> Result<Self, FromArmaError> {
Ok(Self(value.parse::<f64>().map_err(|_| FromArmaError::InvalidValue("Invalid height".into()))?))
Ok(Self(value.parse::<f64>().map_err(|_| {
FromArmaError::InvalidValue("Invalid height".into())
})?))
}
}

Expand Down
8 changes: 3 additions & 5 deletions extension/src/common/types/muzzle_velocity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ impl MuzzleVelocity {

impl FromArma for MuzzleVelocity {
fn from_arma(value: String) -> Result<Self, FromArmaError> {
Ok(Self(
value
.parse::<f64>()
.map_err(|_| FromArmaError::InvalidValue("Invalid muzzle velocity".into()))?,
))
Ok(Self(value.parse::<f64>().map_err(|_| {
FromArmaError::InvalidValue("Invalid muzzle velocity".into())
})?))
}
}

Expand Down
20 changes: 15 additions & 5 deletions extension/src/common/types/temperature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,33 @@ impl Temperature {
impl FromArma for Temperature {
fn from_arma(s: String) -> Result<Self, FromArmaError> {
if s.is_empty() {
return Err(FromArmaError::InvalidValue("unexpected empty string".into()));
return Err(FromArmaError::InvalidValue(
"unexpected empty string".into(),
));
}
match s.chars().next().unwrap() {
'c' => {
let temp = s[1..].parse::<f64>().map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
let temp = s[1..]
.parse::<f64>()
.map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
Ok(Self::new_celsius(temp))
}
'f' => {
let temp = s[1..].parse::<f64>().map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
let temp = s[1..]
.parse::<f64>()
.map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
Ok(Self::new_fahrenheit(temp))
}
'k' => {
let temp = s[1..].parse::<f64>().map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
let temp = s[1..]
.parse::<f64>()
.map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
Ok(Self::new_kelvin(temp))
}
_ => {
let temp = s.parse::<f64>().map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
let temp = s
.parse::<f64>()
.map_err(|e| FromArmaError::InvalidValue(format!("{e}")))?;
Ok(Self::new_celsius(temp))
}
}
Expand Down
2 changes: 1 addition & 1 deletion extension/src/common/types/vector3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use arma_rs::{FromArma, IntoArma, FromArmaError};
use arma_rs::{FromArma, FromArmaError, IntoArma};

#[derive(Debug, Clone, Copy, PartialEq, Default)]
pub struct Vector3 {
Expand Down

0 comments on commit 3417b81

Please sign in to comment.