View taneb.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::Unfold; | |
fn next(arg: &mut (int, int)) -> Option<int> { | |
let (lo, hi) = *arg; | |
*arg = (hi, lo + hi); | |
Some(lo) | |
} | |
fn main() { | |
for fib in Unfold::new((0,1), next).take(20) { |
View taneb2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::Unfold; | |
fn main() { | |
for fib in next.unfold((0,1)).take(20) { | |
println!("{}", fib); | |
}; | |
} | |
fn next(arg: &mut (int, int)) -> Option<int> { | |
let (lo, hi) = *arg; |
View taneb3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::iter::Unfold; | |
fn main() { | |
for fib in (0,1).unfold(next).take(20) { | |
println!("{}", fib); | |
}; | |
} | |
fn next(arg: &mut (int, int)) -> Option<int> { | |
let (lo, hi) = *arg; |
View pyon.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
println!("{:i}", sum([1,2,3,4,5])); | |
} | |
fn sum(x: &[int]) -> int { | |
match x { | |
[head, ..tail] => sum(tail) + head, | |
[] => 0 | |
} | |
} |
View buf.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut w = std::io::BufferedWriter::new(std::io::stdio::stdout()); | |
for _ in range(0, 256) { | |
w.write_char('b'); | |
} | |
w.flush(); | |
} |
View gist:8979798
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rust-git | |
[thestinger] | |
SigLevel = Optional | |
Server = http://pkgbuild.com/~thestinger/repo/$arch |
View um.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut pixels = [0f32, ..8]; | |
for &mut pixel in pixels.mut_iter() { | |
pixel = 2.0; | |
} | |
println!("{:?}", pixels); // [0f32, 0f32, 0f32, 0f32, 0f32, 0f32, 0f32, 0f32] | |
} |
View perx.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::f32::consts::PI; | |
use std::io::{BufferedWriter, stdout}; | |
use std::rand::{Rng, StdRng}; | |
struct Vec2 { | |
x: f32, | |
y: f32, | |
} | |
fn lerp(a: f32, b: f32, v: f32) -> f32 { a * (1.0 - v) + b * v } |
View repr.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repr.rs:5:5: 5:15 error: discriminant value outside specified type | |
repr.rs:5 Qux = 5000 | |
^~~~~~~~~~ | |
repr.rs:1:8: 1:10 note: discriminant type specified here | |
repr.rs:1 #[repr(i8)] | |
^~ |
View um.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn foo<T, U>(x: T) -> U { | |
x // error: mismatched types: expected `U` but found `T` (expected type parameter but found type parameter) | |
} | |
fn main() { | |
foo(1u); | |
} |
OlderNewer