pub fn deserialize_rw_lock_option_number_from_string<'de, T, D>(
deserializer: D,
) -> Result<RwLock<Option<T>>, D::Error>
Expand description
Deserializes a RwLock
option number from string or a number. Same logic as "deserialize_option_number_from_string"
.
ยงExample:
use serde_aux::prelude::*;
use std::sync::RwLock;
#[derive(Debug, serde::Deserialize)]
struct MyStruct {
#[serde(default, deserialize_with = "deserialize_rw_lock_option_number_from_string")]
v: RwLock<Option<f32>>
}
let a = serde_qs::from_str::<MyStruct>("v=-0.1").unwrap();
assert_eq!(*a.v.read().unwrap(), Some(-0.1));