Fix panic when input is empty string
This commit is contained in:
parent
c59918b080
commit
5d08f59083
@ -91,9 +91,6 @@ It's pretty fast and scales well. In my case, it usually runs in under 0.1ms. Th
|
||||
|
||||
To see how fast it is, you can pass the `--debug` flag in CLI, or the `debug` argument to `eval()`.
|
||||
|
||||
## Errors
|
||||
cpc returns `Result`s with basic strings as errors. Just to be safe, you may want to handle panics (You can do that using `std::panic::catch_unwind`).
|
||||
|
||||
## Dev Instructions
|
||||
|
||||
### Get started
|
||||
|
||||
@ -21,6 +21,10 @@ pub const fn is_alphabetic_extended(input: &char) -> bool {
|
||||
/// Lex an input string and return a [`TokenVector`]
|
||||
pub fn lex(input: &str, allow_trailing_operators: bool, default_degree: Unit) -> Result<TokenVector, String> {
|
||||
|
||||
if input == "" {
|
||||
return Err(format!("Input was empty"))
|
||||
}
|
||||
|
||||
let mut input = input.replace(",", ""); // ignore commas
|
||||
input = input.to_lowercase();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user