This file contains hidden or 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
//! Monad chain macro in Rust | |
//! | |
//! A typical usage is to avoid nested match expressions. | |
//! | |
//! Supports: | |
//! - Pattern matching | |
//! - Or expressions (A | B => ...) | |
//! - Guarded statements (x if <cond> => ...) | |
#[feature(macro_rules)]; |
This file contains hidden or 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
package scratch.unsafe; | |
import java.util.Random; | |
public class Today { | |
public static void main(String[] args) { | |
String foo; | |
try { | |
if(new Random().nextBoolean()) { |
This file contains hidden or 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(macro_rules)]; | |
extern mod std; | |
use std::io::IoResult; | |
macro_rules! if_ok_all( | |
//Note that the Err case in these just returns, b/c this little demo is just running | |
//from main and so can't return an IoResult. |
This file contains hidden or 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
//#[no_uv]; //Works as expected w/ no_uv | |
extern mod std; | |
use std::{rand, task, vec}; | |
use std::rand::Rng; | |
use std::hashmap::HashMap; | |
use std::task::TaskBuilder; | |
This file contains hidden or 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
extern mod std; | |
extern mod extra; | |
use std::{num, util}; | |
fn msum_10927(vals: &[f64]) -> f64 { | |
let mut partials : ~[f64] = ~[]; | |
// `partials` is already borrowed when looping | |
// use `modifications` to update `partials` |
This file contains hidden or 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::task; | |
use std::task::TaskBuilder; | |
enum MultiCastMsgChan<T> { | |
Msg(T), | |
MsgChan(Chan<T>) | |
} | |
struct MultiCast<T> { | |
priv ch: Chan<MultiCastMsgChan<T>>, |
This file contains hidden or 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
extern mod std; | |
struct Foo([u8,..2]); | |
struct Bar([u8,..4]); | |
macro_rules! fixed_iter_bytes( | |
($t:ty) => ( | |
impl IterBytes for $t { | |
fn iter_bytes(&self, lsb0: bool, f: std::to_bytes::Cb) -> bool { | |
self.as_slice().iter_bytes(lsb0, f) |
This file contains hidden or 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 ip6_to_str(ip6: &[u8]) -> ~str { | |
let f = u8::to_str_radix; | |
return fmt!("%s%s:%s%s:%s%s:%s%s:%s%s:%s%s:%s%s:%s%s", | |
f(ip6[ 0], 16), f(ip6[ 1], 16), | |
f(ip6[ 2], 16), f(ip6[ 3], 16), | |
f(ip6[ 4], 16), f(ip6[ 5], 16), | |
f(ip6[ 6], 16), f(ip6[ 7], 16), | |
f(ip6[ 8], 16), f(ip6[ 9], 16), | |
f(ip6[10], 16), f(ip6[11], 16), | |
f(ip6[12], 16), f(ip6[13], 16), |
This file contains hidden or 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
#include<stdio.h> | |
main() { | |
long long a = -9223372036854775808; | |
long long b = a * -1; | |
printf("%lld\n", b); | |
} |
This file contains hidden or 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
extern mod extra; | |
use std::{int,io,result,task}; | |
use extra::{net,net_tcp,uv}; | |
fn server(outer_ch: Chan<Chan<~str>>) { | |
let (accept_port, accept_chan) = stream(); | |
let (finish_port, finish_chan) = stream(); | |
let addr = extra::net_ip::v4::parse_addr("127.0.0.1"); |
NewerOlder