Use of assert_eq()

Is assert_eq() meant to crash the app (ie. exit the program) upon evaluation to false? That means, we should not use this method to evaluate user input?

If so, what is a convenient way to evaluate use user input, say from a web form?

asserts in Rust and most languages are intended as fault finding aids. They should never fire off in normal running. They are there to halt everything with a meaningful message in cases when something is very wrong with the logic of your code.

How you evaluate, clean, or otherwise handle user input is as per any other language. Have a look at https://doc.rust-lang.org/std/primitive.str.html#method.parse for starters.

2 Likes

Good explanation and just what I thought! Thanks!