Refactoring de la variable result_bytes_read dans main.rs
This commit is contained in:
parent
4a4dd5817b
commit
f4fb13c96e
1 changed files with 4 additions and 4 deletions
|
@ -5,7 +5,7 @@ mod parser;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
let mut result_bytes_read: io::Result<usize>;
|
let mut bytes_read_result: io::Result<usize>;
|
||||||
let mut bytes_read: usize = 1;
|
let mut bytes_read: usize = 1;
|
||||||
|
|
||||||
while bytes_read != 0 {
|
while bytes_read != 0 {
|
||||||
|
@ -15,13 +15,13 @@ fn main() {
|
||||||
if io::stdout().flush().is_err() {
|
if io::stdout().flush().is_err() {
|
||||||
eprintln!("error: can't fully flush stdout or reached EOF");
|
eprintln!("error: can't fully flush stdout or reached EOF");
|
||||||
}
|
}
|
||||||
result_bytes_read = io::stdin().read_line(&mut buffer);
|
bytes_read_result = io::stdin().read_line(&mut buffer);
|
||||||
|
|
||||||
if result_bytes_read.is_err() {
|
if bytes_read_result.is_err() {
|
||||||
eprintln!("error: invalid UTF-8 characters were read");
|
eprintln!("error: invalid UTF-8 characters were read");
|
||||||
bytes_read = 1;
|
bytes_read = 1;
|
||||||
} else {
|
} else {
|
||||||
bytes_read = result_bytes_read.unwrap();
|
bytes_read = bytes_read_result.unwrap();
|
||||||
if bytes_read != 0 {
|
if bytes_read != 0 {
|
||||||
let command_vec: Vec<String> = parser::parse(&buffer);
|
let command_vec: Vec<String> = parser::parse(&buffer);
|
||||||
println!("{:?}", command_vec);
|
println!("{:?}", command_vec);
|
||||||
|
|
Reference in a new issue