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] 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"); }