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
use crate::imp::structs::var_type::VarType;
use crate::imp::structs::qv::Qv;
use crate::IdentityEqual;
#[derive(Debug, PartialEq, Clone)]
pub struct RefValue{
v : Box<RefValueInternal>,
}
#[derive(Debug, PartialEq, Clone)]
struct RefValueInternal{
value : Qv<String>,
value_type : VarType,
}
#[derive(Debug, PartialEq, Clone)]
pub struct RefSabValue{
value : Box<Qv<String>>,
}
impl RefValue{
pub(crate) fn new(value : Qv<String>, value_type : VarType) -> RefValue{
RefValue{ v : Box::new(RefValueInternal{value, value_type }) }
}
pub(crate) fn var_type(&self) -> VarType { self.v.value_type }
pub fn value(&self) -> &Qv<String>{ &self.v.value }
pub(crate) fn into_sab_value(self) ->RefSabValue{ RefSabValue::new(self.value().clone()) }
pub(crate) fn acceptable(&self, other : &RefSabValue) -> bool{
self.var_type().acceptable(&other.value.qv_type())
}
}
impl RefSabValue{
pub fn new(value : Qv<String>) -> RefSabValue{ RefSabValue{ value : Box::new(value) } }
pub fn value(&self) -> &Qv<String>{ &self.value }
pub(crate) fn into_ref_value_for_json(self) -> RefValue{
RefValue::new(self.value().clone(), VarType::Normal)
}
}
impl IdentityEqual for RefSabValue{
fn identity_eq(&self, other: &Self) -> bool {
self.value.identity_eq(other.value())
}
}