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
pub trait FromJson { | |
fn from_json(j :&Json) -> Result<Self, ValueError>; | |
} | |
impl<T: FromJson> FromJson for Option<T> { | |
fn from_json(j: &Json) -> Result<Option<T>, ValueError> { | |
match *j { | |
Null => Ok(None), | |
otherwise => { | |
let t = FromJson::from_json(&otherwise); |
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
#[test] | |
fn test_req() { | |
let url = match url::from_str("http://www.reddit.com") { | |
Ok(url) => { | |
println(url.to_str()); | |
url | |
} | |
Err(msg) => fail!("\\{ url: {0}, err: {1} \\}","http://www.reddit.com", msg), | |
}; |
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
trait Plode { | |
fn explode(&mut self) -> ~str { | |
~"Boom" | |
} | |
fn implode(&mut self) -> ~str { | |
~"Pop" | |
} | |
} |
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 mutate(x: &mut int) -> int { | |
let ret = x.clone(); | |
*x += 100; | |
ret | |
} | |
fn main() { | |
let mut x = -5; | |
x += 5; |
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 Test { | |
mem: int, | |
mem2: int, | |
} | |
pub static g_test: Test = Test { | |
mem: 0, | |
mem2: 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
fn slice_from_c_str<'a>(cstr: *c_char) -> &'a str { | |
unsafe { | |
cast::transmute_region(str::raw::c_str_to_static_slice(cstr)) | |
} | |
} | |
config.rs:49 cast::transmute_region(str::raw::c_str_to_static_slice(cstr)) | |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
config.rs:48:4: 50:5 error: mismatched types: expected `&'a str` but found `&<V1>` (expected &'a str but found &-ptr) | |
config.rs:48 unsafe { |
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
#[deriving(TotalEq, ToStr, Clone)] | |
enum Color { | |
Red, | |
Black | |
} | |
impl Not<Color> for Color { | |
#[inline] | |
fn not(&self) -> Color { | |
match *self { |
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
md_ref = line.split_iter(' ') | |
.transform(|s| s.to_owned()) | |
.collect::<~[~str]>()[2] | |
.iter() | |
.collect::<~[char]>() | |
.chunk_iter(2) | |
.transform(|cs| { | |
let s = str::from_chars(cs); | |
println(s); | |
u8::from_str_radix(s, 16).get() |
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
/* | |
The Keccak sponge function, designed by Guido Bertoni, Joan Daemen, | |
Michaël Peeters and Gilles Van Assche. For more information, feedback or | |
questions, please refer to our website: http://keccak.noekeon.org/ | |
Implementation by the designers, | |
hereby denoted as "the implementer". | |
To the extent possible under law, the implementer has waived all copyright | |
and related or neighboring rights to the source code in this file. |
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
STATUS_CODES | |
genShortMsg(int hashbitlen) | |
{ | |
char fn[32], line[SUBMITTER_INFO_LEN]; | |
int msglen, msgbytelen, done; | |
BitSequence Msg[256], MD[64]; | |
FILE *fp_in, *fp_out; | |
if ( (fp_in = fopen("ShortMsgKAT.txt", "r")) == NULL ) { | |
printf("Couldn't open <ShortMsgKAT.txt> for read\n"); |