candy-rs

Syntaxic sugar for Rust

Repository Latest version Documentation License

Example

```rust

[macro_use] extern crate candy;

use ::std::*;

type ErrorMsg = borrow::Cow<'static, str>;

fallible!{ fn main () -> () =>! ErrorMsg : let inputnumber: u64 = { let (mbargv0, mbargv1) = { let mut args = env::args(); (args.next(), args.next()) }; let progname = mbargv0.unwrap(); match mbargv1 .andthen(|argv1| argv1.parse().ok()) { Some(number) => number, _ => throw!(format!("Usage: {} ", progname)), } }; collatzconjecture(inputnumber); }

fn collatzconjecture (mut n: u64) { doloop!({ println!("n = {}", n); if n % 2 == 0 { n /= 2; } else { n = 3 * n + 1; }; } while n != 1); println!("Did reach 1."); } ```

Usage