1
0
Fork 0
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:
Quaternions 2025-02-14 10:23:11 -08:00 committed by Robin Appelman
commit 63e36fb1f8

View file

@ -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)
}
} }