diff --git a/src/lib.rs b/src/lib.rs index 72e16a5..de71adc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -152,6 +152,28 @@ fn is_string_numeric(str: String) -> bool { return true; } +pub trait Quote { + fn quote(&self) -> String; +} + +impl Quote for String { + #[inline] + fn quote(&self) -> String { + format!("\"\"\"\n{}\n\"\"\"", self).to_string() + } +} + +pub trait Unquote { + fn unquote(&self) -> String; +} + +impl Unquote for String { + #[inline] + fn unquote(&self) -> String { + self.trim_matches('\"').trim_matches('\n').to_string() + } +} + #[cfg(test)] mod test { use crate::{from_base36, ToBase36, optional_data_line, mock, segments_from_string}; diff --git a/src/room.rs b/src/room.rs index cd4ee0e..74aa3b5 100644 --- a/src/room.rs +++ b/src/room.rs @@ -110,7 +110,7 @@ impl From for Room { } let lines = &lines[1..]; - + let dimension = lines.len(); // x or y, e.g. `16` for 16x16 let mut tiles: Vec = Vec::new(); for line in lines.into_iter() { @@ -120,7 +120,7 @@ impl From for Room { .collect(); if ! comma_separated { line = line[1..].to_owned(); } - let line = line[..16].to_owned(); + let line = line[..dimension].to_owned(); for tile_id in line { tiles.push(tile_id.to_string());