Project for porting C to Rust gains Mozilla's backing (InfoWorld)
Project for porting C to Rust gains Mozilla's backing (InfoWorld)
Posted Nov 2, 2016 12:26 UTC (Wed) by valarauca (guest, #109490)In reply to: Project for porting C to Rust gains Mozilla's backing (InfoWorld) by vasvir
Parent article: Project for porting C to Rust gains Mozilla's backing (InfoWorld)
In non-debug builds the Rust integer addition mirrors the C integer addition. Overflow/underflow will behave according to the platform specification.
The developer can opt-into checked addition (actually most integer operations can be check) which returns an Option<usize> (usize is being used here as an example, usize in Rust is the same as C's size_t). The Option<usize> is just a tagged union of char, size_t where the char signals if overflow occurred.
Here [1] is a simple playpen link where you can see the various ASM generated the different levels (debug/release).
[1] https://play.rust-lang.org/?gist=2bd93049475dda6e75e345a9...
