How do I convert a String to an integer in Rust? [duplicate]
Note that parsing a number from a string can fail, so a Result is returned. For this example, we panic on a failure case using expect. Additionally, read_line leaves the newline from pressing Enter, so trim is used to ignore that before parsing.