mirror of
https://codeberg.org/icewind/vbsp.git
synced 2026-06-03 18:54:05 +02:00
central bool_from_int
This commit is contained in:
parent
3bb3d8f795
commit
63e36fb1f8
1 changed files with 6 additions and 5 deletions
|
|
@ -275,9 +275,15 @@ impl<'de> Deserialize<'de> for LightColor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn bool_from_int<'de, D: Deserializer<'de>>(deserializer: D) -> Result<bool, D::Error> {
|
||||||
|
let int = u8::deserialize(deserializer)?;
|
||||||
|
Ok(int != 0)
|
||||||
|
}
|
||||||
|
|
||||||
pub use typed::*;
|
pub use typed::*;
|
||||||
|
|
||||||
mod typed {
|
mod typed {
|
||||||
|
use crate::bool_from_int;
|
||||||
use crate::{Angles, Color, LightColor, Vector};
|
use crate::{Angles, Color, LightColor, Vector};
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
|
|
||||||
|
|
@ -934,9 +940,4 @@ mod typed {
|
||||||
#[serde(rename = "startactive", deserialize_with = "bool_from_int")]
|
#[serde(rename = "startactive", deserialize_with = "bool_from_int")]
|
||||||
pub start_active: bool,
|
pub start_active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bool_from_int<'de, D: Deserializer<'de>>(deserializer: D) -> Result<bool, D::Error> {
|
|
||||||
let int = u8::deserialize(deserializer)?;
|
|
||||||
Ok(int > 0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue