Skip to content

Instantly share code, notes, and snippets.

@psyomn
Created November 1, 2012 01:32
Show Gist options
  • Save psyomn/3991057 to your computer and use it in GitHub Desktop.
Save psyomn/3991057 to your computer and use it in GitHub Desktop.
Circlejerking with Rust
/**
test comments
*/
fn main()
{
io::println("HELLO WORLD");
let x: int = add_numbers(12,21);
io::println(fmt!("Add numbers function : %d" , x));
io::println(fmt!("Cound and add numbers : %?" , count_and_add_numbers(10)));
call_later();
nice_for();
return;
}
fn call_later()
{
io::println("You called this from a function");
}
fn add_numbers(num1: int, num2: int) -> int
{
return num1 + num2;
}
fn count_and_add_numbers(num : int) -> int
{
let mut accumulator: int = 0;
let mut counter: int = num;
while counter > 0
{
accumulator += counter;
counter -= 1;
}
return accumulator;
}
fn nice_for()
{
for ["hello", "there", "francis"].each |text| {
io::println(fmt!("%?", text));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment