use super::story::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"
);
}
}