ttvm 0.3.8

Runtime and compiler infrastructure API for Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::*;

// Flip the sign of a number.
pub fn flip(byte: Byte) -> Byte {
    let mut string = byte.to_string();

    if string.starts_with("-") {
        string.remove(0);
    } else {
        string.insert(0, '-');
    }

    match string.parse::<Byte>() {
        Ok(ok) => ok,
        Err(_) => 0
    }
}