From 630e5e05b1c1e114485284a41c59558d8f54cad2 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> Date: Tue, 13 Oct 2020 10:19:34 +0200 Subject: [PATCH 1/2] func to get file content as Result --- src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index c10155e..7520c9b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,11 @@ fn parse_instruction(c: char) -> Result { } } -fn main() { - let file_data = include_str!("../two_robots.txt"); +fn open_file(filename: &str) -> io::Result { + let content = fs::read_to_string(filename)?; + Ok(content) +} + +fn main() { + let conf = open_file("two_robots.txt"); } From 3106882ddbfac647724c6047c2de3a7056da5ba4 Mon Sep 17 00:00:00 2001 From: Volodymyr Patuta <90917-fiplox@users.noreply.framagit.org> Date: Tue, 13 Oct 2020 10:31:50 +0200 Subject: [PATCH 2/2] Update main.rs --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.rs b/src/main.rs index 7520c9b..6d12ddd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +use std::fs; +use std::io; + enum Orientation { N, E,