library: serialize: add vector_normalizer helper
This commit is contained in:
parent
a90d4d9405
commit
76db818fa8
|
@ -0,0 +1,2 @@
|
|||
pub mod vector;
|
||||
pub use vector::*;
|
10
src/serialize/vector.rs
Normal file
10
src/serialize/vector.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
use crate::Vector;
|
||||
use serde::de::{Deserialize, Deserializer};
|
||||
|
||||
pub fn vector_normalizer<'de, D>(deserializer: D) -> Result<Vector, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let v: Vector = Deserialize::deserialize(deserializer)?;
|
||||
Ok(v.normalize())
|
||||
}
|
Loading…
Reference in a new issue