From c972102a38a24bf281e89756d66c5d20fb033a74 Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Wed, 1 Nov 2023 13:34:33 +0100 Subject: [PATCH] Ajout : module io, modification des use --- src/io.rs | 3 +++ src/main.rs | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 src/io.rs diff --git a/src/io.rs b/src/io.rs new file mode 100644 index 0000000..4c95642 --- /dev/null +++ b/src/io.rs @@ -0,0 +1,3 @@ +pub fn run() -> i32 { + todo!(); +} diff --git a/src/main.rs b/src/main.rs index 94ef145..364adc2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,21 +1,27 @@ -use std::io; -use std::io::Write; +use std::io as stdio; +use stdio::{ + stdin, + stdout, + Write, +}; +use std::process::exit; mod parser; +mod io; fn main() { let mut buffer = String::new(); - let mut bytes_read_result: io::Result; + let mut bytes_read_result: stdio::Result; let mut bytes_read: usize = 1; while bytes_read != 0 { buffer.clear(); print!("$ "); - if io::stdout().flush().is_err() { + if stdout().flush().is_err() { eprintln!("error: can't fully flush stdout or reached EOF"); } - bytes_read_result = io::stdin().read_line(&mut buffer); + bytes_read_result = stdin().read_line(&mut buffer); if bytes_read_result.is_err() { eprintln!("error: invalid UTF-8 characters were read");