wang_utils/hashmap/
setter.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::hashmap::MapValue;

impl From<&str> for MapValue {
    fn from(value: &str) -> Self {
        MapValue::String(value.to_string())
    }
}
impl From<String> for MapValue {
    fn from(value: String) -> Self {
        MapValue::String(value)
    }
}
impl From<i16> for MapValue {
    fn from(value: i16) -> Self {
        MapValue::I16(value)
    }
}
impl From<u16> for MapValue {
    fn from(value: u16) -> Self {
        MapValue::U16(value)
    }
}
impl From<i32> for MapValue {
    fn from(value: i32) -> Self {
        MapValue::I32(value)
    }
}
impl From<u32> for MapValue {
    fn from(value: u32) -> Self {
        MapValue::U32(value)
    }
}
impl From<f32> for MapValue {
    fn from(value: f32) -> Self {
        MapValue::F32(value)
    }
}
impl From<i64> for MapValue {
    fn from(value: i64) -> Self {
        MapValue::I64(value)
    }
}
impl From<u64> for MapValue {
    fn from(value: u64) -> Self {
        MapValue::U64(value)
    }
}
impl From<f64> for MapValue {
    fn from(value: f64) -> Self {
        MapValue::F64(value)
    }
}
impl From<bool> for MapValue {
    fn from(value: bool) -> Self {
        MapValue::Bool(value)
    }
}
impl<T> From<Option<T>> for MapValue
where
    T: Into<MapValue>,
{
    fn from(value: Option<T>) -> Self {
        MapValue::OptionValue(value.map(|v| Box::new(v.into())))
    }
}