[][src]Attribute Macro plutonium::fallout

#[fallout]

Fallthrough match arms

#[fallout]
fn switch(x: i32) -> String {
    let mut s = String::new();
    match x {
        1 => s += "1",
        2 => s += "2",
        _ => ( /* do nothing */ ),
    }
    s
}
assert_eq!(switch(1), "12".to_string());

Use breaks to deconvolve match arms:

#[fallout]
fn speaker(boxxx: Box<i32>) -> &'static str {
    match *boxxx {
        13 => { "13"; break; },
        14 => "14",
        _ => "lol",
    }
}
assert_eq!(speaker(Box::new(13)), "13");
assert_eq!(speaker(Box::new(14)), "lol");

Behold, the revenant:

#[fallout]
fn send(from: *const i16, to: *mut i16, count: i32) {
    let mut pos = from;
    let n = (count + 7) / 8;
    unsafe {
        match count % 8 {
            0 => { *to = *pos; pos = pos.add(1); },
            7 => { *to = *pos; pos = pos.add(1); },
            6 => { *to = *pos; pos = pos.add(1); },
            5 => { *to = *pos; pos = pos.add(1); },
            4 => { *to = *pos; pos = pos.add(1); },
            3 => { *to = *pos; pos = pos.add(1); },
            2 => { *to = *pos; pos = pos.add(1); },
            1 => { *to = *pos; pos = pos.add(1); },
            _ => (),
        }
        for _ in (1..n).rev() {
            *to=*pos;   pos   =  pos.add(1);  *to=*pos;pos     =pos.add(1);
            *to    =*   pos   ;  pos          =pos         .add(1);
            *to    =*   pos   ;  pos=pos.add  (1);*to=*pos   ;pos=pos.add(1);
            *to    =*   pos   ;  pos          =pos                 .add(1);
            *to    =*   pos   ;  pos          =pos             .add(1);
            *to = *pos ;pos =    pos          .add         (1);
        }
    }
}