From 89c3377d06297fdbca376f2d03e53c4af0d6709c Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Fri, 29 Mar 2019 20:11:16 +0530 Subject: handle empty lines --- src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main.rs b/src/main.rs index ddad9b4..c111bf1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,6 +35,7 @@ use rustyline::config::{ Builder, ColorMode, EditMode }; fn main() { + let args: Vec = env::args().collect(); if args.len() > 1 { let mut expr = String::new(); @@ -114,6 +115,9 @@ fn autobalance_parens(input: &str) -> Result { } fn eval_math_expression(input: &str) -> Result { + if input.len() == 0 { + return Ok(0.) + } let input = autobalance_parens(&input[..])?; let lexed = lexer(&input[..])?; let postfixed = to_postfix(lexed)?; -- cgit v1.2.3