umya_spreadsheet/structs/
int64_value.rs

1#[derive(Clone, Default, Debug)]
2pub struct Int64Value {
3    value: Option<i64>,
4}
5impl Int64Value {
6    #[inline]
7    pub(crate) fn get_value(&self) -> &i64 {
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: i64) -> &mut Int64Value {
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 Int64Value {
27        self.set_value(value.into().parse::<i64>().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}