Skip to content

Commit eab3a5f

Browse files
committed
small refactor and remove newline character
1 parent bb6a457 commit eab3a5f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/repl.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ impl Repl {
3636
loop {
3737
print!("{}=> ",self.environment.get_current_namespace_name());
3838
let _ = io::stdout().flush();
39-
let mut next = Value::Nil;
4039

41-
// a scope for stdin to be released for providing input for function
42-
{
40+
let next = {
4341
let mut stdin_reader = stdin.lock();
4442
// Read
45-
next = Repl::read(&mut stdin_reader);
46-
}
43+
Repl::read(&mut stdin_reader)
44+
// Release stdin.lock
45+
};
4746

4847
// Eval
4948
let evaled_next = self.eval(&next);

src/rust_core/read_line.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ impl IFn for ReadLineFn {
2222
if args.len() != 0 {
2323
return error_message::wrong_arg_count(0, args.len())
2424
}
25-
2625
let mut input = String::new();
2726
io::stdout().flush();
2827
match io::stdin().read_line(&mut input) {
29-
Ok(_) => Value::String(input),
28+
Ok(_) => {
29+
input.pop();
30+
Value::String(input)
31+
},
3032
Err(error) => error_message::generic_err(Box::try_from(error).unwrap())
3133
}
3234
}

0 commit comments

Comments
 (0)