Ajout : module io, modification des use
This commit is contained in:
parent
f4fb13c96e
commit
c972102a38
2 changed files with 14 additions and 5 deletions
3
src/io.rs
Normal file
3
src/io.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn run() -> i32 {
|
||||
todo!();
|
||||
}
|
16
src/main.rs
16
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<usize>;
|
||||
let mut bytes_read_result: stdio::Result<usize>;
|
||||
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");
|
||||
|
|
Reference in a new issue