umya_spreadsheet/structs/
int16_value.rs

1#[derive(Clone, Default, Debug)]
2pub struct Int16Value {
3    #[allow(dead_code)]
4    value: Option<i16>,
5}
6impl Int16Value {
7    #[inline]
8    pub(crate) fn _get_value(&self) -> &i16 {
9        match &self.value {
10            Some(v) => v,
11            None => &0,
12        }
13    }
14
15    #[inline]
16    pub(crate) fn _get_value_string(&self) -> String {
17        self._get_value().to_string()
18    }
19
20    #[inline]
21    pub(crate) fn _set_value(&mut self, value: i16) -> &mut Int16Value {
22        self.value = Some(value);
23        self
24    }
25
26    #[inline]
27    pub(crate) fn _set_value_string<S: Into<String>>(&mut self, value: S) -> &mut Int16Value {
28        self._set_value(value.into().parse::<i16>().unwrap())
29    }
30
31    #[inline]
32    pub(crate) fn _has_value(&self) -> bool {
33        self.value.is_some()
34    }
35
36    #[inline]
37    pub(crate) fn _get_hash_string(&self) -> String {
38        if self._has_value() {
39            return self._get_value_string();
40        }
41        String::from("empty!!")
42    }
43}