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::story::types::LineBuffer;
pub fn copy_lines_into_string(line_buffer: &LineBuffer) -> String {
line_buffer
.iter()
.map(|line| line.text.clone())
.collect::<Vec<_>>()
.join("")
}
#[cfg(test)]
mod tests {
use super::*;
use crate::story::Line;
#[test]
fn string_from_line_buffer_joins_without_extra_newlines() {
let lines = vec![
Line {
text: "Start of line, ".to_string(),
tags: Vec::new(),
},
Line {
text: "end of line without new lines".to_string(),
tags: Vec::new(),
},
];
assert_eq!(
©_lines_into_string(&lines),
"Start of line, end of line without new lines"
);
}
}