Redundant Check in Rust Parsing Loop: None After is_empty() — Is It Required?

63 points Karanmj7

I am working on lisp interpreter, in that i am writing parser rn, i following the lisp interpreter in rust guide, in that i found this code, which is little confusing to me,

​

at line number 41 if we are checking for is\_empty for while loop condition, then why do we need to check None at 43,

​

I am not able to think of the scenario in the parser where this will happen, if parser didn't find token then it will not enter the while loop itself, right ?

​

i am new to rust and learning rust, completed 50% book and rustlings, so please forgive me if this is dumb question

​

​

code link:https://github.com/vishpat/lisp-rs/blob/0.0.1/src/parser.rs

https://preview.redd.it/29udgo1oizec1.png?width=1362&format=png&auto=webp&s=4e609e30b2af1da82b72415a7c80d2ec1dd5c46d

​