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() {} | |
fn unwrap_array<T>(input: [Option<T>; 2]) -> Option<[T; 2]> { | |
// Note: `{ }` is required here. | |
match {input} { | |
[Some(a), Some(b)] => Some([a, b]), | |
_ => None, | |
} | |
} |
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::io::{Read, Write}; | |
use std::fs::File; | |
fn main() { | |
let args = ::std::env::args().collect::<Vec<_>>(); | |
// skip the program name | |
if args.len() != 5 { | |
println!("Usage: {} <filename> <columnname> <replacement> <output_filename>", args[0]); | |
} | |
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
//replacement constant | |
pub const P: [u8; 256] = [ | |
60, 63, 58, 160, 99, 193, 14, 189, 7, 116, 255, 230, 172, | |
201, 132, 186, 10, 203, 211, 20, 180, 106, 0, 21, 174, 119, | |
39, 225, 238, 38, 208, 76, 223, 216, 213, 150, 118, 77, 82, | |
42, 125, 68, 34, 232, 107, 252, 195, 247, 243, 169, 248, 120, | |
254, 123, 171, 103, 146, 65, 98, 61, 147, 114, 67, 134, 251, | |
59, 234, 87, 88, 53, 40, 196, 79, 168, 95, 113, 104, 83, | |
36, 73, 57, 190, 249, 75, 242, 129, 143, 110, 237, 94, 145, | |
97, 179, 197, 206, 24, 1, 16, 128, 89, 45, 101, 71, 192, |
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::collections::HashMap; | |
fn main() { | |
let port = "1025"; | |
// Works if I reverse these two lines | |
let mut data = HashMap::new(); | |
let port = port.to_string(); | |
data.insert("port", &port); |
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
#![feature(box_patterns)] | |
pub enum Expression { | |
Identifier(String), | |
Function(String, Box<Expression>), | |
Application(Box<Expression>, Box<Expression>), | |
} | |
impl Expression { | |
fn is_variable_free(&self, var: &str) -> bool { |
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::io::timer; | |
use std::time::Duration; | |
use std::sync::Future; | |
trait Constraint { | |
fn is_satisfied(&self) -> bool; | |
} | |
#[deriving(Send)] | |
struct Foo { | |
name: &'static str, |
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
struct Car { | |
color: ~str, | |
miles: int, | |
} | |
impl Car { | |
fn new() -> ~Car { ~Car{color: ~"none", miles: 0,} } | |
} | |
macro_rules! simple_eq(( $ T : ident -> $ l : ident , $ r : expr ) => | |
( | |
{ let temp = $ T :: new ( ) ; & temp . $ l == & temp . |