get segments from borrowed str instead of String for flexibility

This commit is contained in:
Max Bradbury 2020-11-06 15:37:00 +00:00
parent 46f8831c7b
commit e992e41635
2 changed files with 3 additions and 5 deletions

View File

@ -125,7 +125,7 @@ impl Game {
}
let string = string.trim_start_matches('\n').to_string();
let mut segments = segments_from_string(string);
let mut segments = segments_from_str(&string);
let mut name = "".to_string();

View File

@ -187,7 +187,7 @@ impl Unquote for String {
#[cfg(test)]
mod test {
use crate::{ToBase36, optional_data_line, mock, segments_from_string, Quote, Unquote, new_unique_id, try_id};
use crate::{ToBase36, optional_data_line, mock, segments_from_str, Quote, Unquote, new_unique_id, try_id};
#[test]
fn to_base36() {
@ -202,9 +202,7 @@ mod test {
#[test]
fn string_to_segments() {
let output = segments_from_string(
include_str!("./test-resources/segments").to_string()
);
let output = segments_from_str(include_str!("./test-resources/segments"));
let expected = vec![
"\"\"\"\nthe first segment is a long bit of text\n\n\nit contains empty lines\n\n\"\"\"".to_string(),