On Tuesday, 23 February 2016 at 07:18:09 UTC, rsw0x wrote:
On Tuesday, 23 February 2016 at 06:49:46 UTC, Tobias Müller wrote:
OTOH in the examples in Kotlin/Rust the variable 'var' changes its type
from 'int?' to plain 'int'.
In Kotlin this is done with static analysis, in Rust with rebinding of the
name.

Tobi

Rust's Option<T> checks are not done at compile-time in most cases unless something changed drastically in the past ~18 months.

Option<T> is an enum type in Rust (i.e. algebraic data type). The Rust compiler forces you to check all possible cases so you can't use it improperly. So you would have to use something like pattern matching or "if let" to check the state.

https://doc.rust-lang.org/book/match.html#matching-on-enums

Reply via email to