umya_spreadsheet/structs/
int32_value.rs

1#[derive(Clone, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
2pub struct Int32Value {
3    value: Option<i32>,
4}
5impl Int32Value {
6    #[inline]
7    pub(crate) fn get_value(&self) -> &i32 {
8        match &self.value {
9            Some(v) => v,
10            None => &0,
11        }
12    }
13
14    #[inline]
15    pub(crate) fn get_value_string(&self) -> String {
16        self.get_value().to_string()
17    }
18
19    #[inline]
20    pub(crate) fn set_value(&mut self, value: i32) -> &mut Self {
21        self.value = Some(value);
22        self
23    }
24
25    #[inline]
26    pub(crate) fn set_value_string<S: Into<String>>(&mut self, value: S) -> &mut Self {
27        self.set_value(value.into().parse::<i32>().unwrap())
28    }
29
30    #[inline]
31    pub(crate) fn has_value(&self) -> bool {
32        self.value.is_some()
33    }
34
35    #[inline]
36    pub(crate) fn get_hash_string(&self) -> String {
37        if self.has_value() {
38            return self.get_value_string();
39        }
40        String::from("empty!!")
41    }
42}