//! Helper functions to deserialize `Vector` values. use crate::Vector; use serde::de::{Deserialize, Deserializer}; /// Deserialize a vector. /// /// Needs a custom implementation to make sur the vector is normalized when deserialized. pub fn vector_normalizer<'de, D>(deserializer: D) -> Result where D: Deserializer<'de>, { let v: Vector = Deserialize::deserialize(deserializer)?; Ok(v.normalize()) }