[rust-dev] Integer from string

2013-05-18 Thread Renato Lenzi
I don't understand why this code is bad: let n1 = int::from_str(line); if n1 == 0 compiler complains: 3.rs:7:12: 7:13 error: mismatched types: expected `core::option::Optionint ` but found `VI0` (expected enum core::option::Option but found integral varia ble) 3.rs:7if n1 == 0

Re: [rust-dev] Integer from string

2013-05-18 Thread Corey Richardson
On Sat, May 18, 2013 at 11:46 AM, Renato Lenzi rex...@gmail.com wrote: I don't understand why this code is bad: let n1 = int::from_str(line); if n1 == 0 compiler complains: 3.rs:7:12: 7:13 error: mismatched types: expected `core::option::Optionint ` but found `VI0` (expected

Re: [rust-dev] Integer from string

2013-05-18 Thread Corey Richardson
On Sat, May 18, 2013 at 11:57 AM, Corey Richardson co...@octayn.net wrote: ``` match int::from_str(line) { Some(x) = n1 = x, None = { /* handle error... */} } if n1 == 0 { ... ``` Amend that to: let n1; match int::from_str(line) { Some(x) = n1 = x, None = { /* handle