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::VojaqLine;
use std::fmt;
#[derive(PartialEq, Eq)]
pub struct VojaqSet {
lines : Vec<VojaqLine>
}
impl VojaqSet {
pub fn new() -> VojaqSet {
VojaqSet {
lines: vec![]
}
}
pub fn with_lines(lines: Vec<VojaqLine>) -> VojaqSet {
VojaqSet {
lines: lines
}
}
pub fn lines(&self) -> &[VojaqLine] {
self.lines.as_slice()
}
pub fn push(&mut self, line: VojaqLine) {
self.lines.push(line);
}
pub fn push_if_not_empty(&mut self, line: VojaqLine) {
if !line.is_empty() {
self.lines.push(line)
}
}
pub fn get(&self, line_index: usize) -> Option<&VojaqLine> {
self.lines.get(line_index)
}
pub fn is_empty(&self) -> bool {
self.lines().iter().all(|line| line.is_empty())
}
}
impl fmt::Debug for VojaqSet {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.lines.fmt(f)
}
}