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
use crate::value::{Value};
use crate::types::*;
impl Value {
pub fn pull(&self) -> Self {
match self.dt {
QUEUE => {
let mut data: Vec<Value> = Vec::new();
match &self.data {
Val::Queue(v) => {
if v.len() > 0 {
for i in &v[1..] {
data.push(i.clone());
}
}
}
_ => {},
}
return Value::to_queue(data);
}
FIFO => {
let mut data: Vec<Value> = Vec::new();
match &self.data {
Val::Queue(v) => {
if v.len() > 0 {
for i in &v[..self.len()-1] {
data.push(i.clone());
}
}
}
_ => {},
}
return Value::to_fifo(data);
}
LIST | RESULT => {
let mut data: Vec<Value> = Vec::new();
match &self.data {
Val::List(v) => {
for i in &v[..self.len()-1] {
data.push(i.clone());
}
}
_ => {},
}
if self.dt == LIST {
return Value::from_list(data);
} else {
return Value::to_result(data);
}
}
_ => {
let mut res = self.dup().unwrap();
res.regen_id();
return res;
}
}
}
}