From 15eb501999eabf3332023071625913ce6881a2b2 Mon Sep 17 00:00:00 2001 From: Max Bradbury Date: Sat, 11 Apr 2020 18:18:20 +0100 Subject: [PATCH] use ready-made function for splitting lines --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8bc07d1..8e0abe5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -353,7 +353,7 @@ fn animation_frames_to_string(animation_frames: Vec) -> String { } fn tile_from_string(string: String) -> Tile { - let mut lines: Vec<&str> = string.split("\n").collect(); + let mut lines: Vec<&str> = string.lines().collect(); let id = lines[0].replace("TIL ", ""); @@ -589,7 +589,7 @@ fn test_avatar_to_string() { } fn sprite_from_string(string: String) -> Sprite { - let mut lines: Vec<&str> = string.split("\n").collect(); + let mut lines: Vec<&str> = string.lines().collect(); let id = lines[0].replace("SPR ", ""); let mut name = None; @@ -659,7 +659,7 @@ fn test_sprite_to_string() { } fn item_from_string(string: String) -> Item { - let mut lines: Vec<&str> = string.split("\n").collect(); + let mut lines: Vec<&str> = string.lines().collect(); let id = lines[0].replace("ITM ", ""); let mut name = None; @@ -783,7 +783,7 @@ fn test_ending_to_string() { } fn dialogue_from_string(string: String) -> Dialogue { - let lines: Vec<&str> = string.split("\n").collect(); + let lines: Vec<&str> = string.lines().collect(); let id = lines[0].replace("DLG ", "").to_string(); let contents = lines[1..].join("\n"); @@ -847,7 +847,7 @@ fn test_variable_to_string() { fn room_from_string(string: String) -> Room { // todo handle room_format? - let mut lines: Vec<&str> = string.split("\n").collect(); + let mut lines: Vec<&str> = string.lines().collect(); let id = lines[0].replace("ROOM ", ""); let mut name = None; let mut palette = "0".to_string();