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
enum Void {} | |
impl Void { | |
fn unreachable(self) -> ! { | |
match self { } | |
} | |
unsafe fn make() -> Void { | |
std::unstable::intrinsics::uninit() | |
} |
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
#include <stdint.h> | |
#include <stdio.h> | |
uint32_t u32 = 0; | |
extern uint8_t u8[4] __attribute__((alias("u32"))); | |
int main() { | |
printf("%08x\n", u32); | |
u8[0] = 1; | |
printf("%08x\n", u32); |
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::cast; | |
struct FooStatics { | |
x: int, | |
} | |
static mut globalFooStatics: *FooStatics = 0 as *FooStatics; | |
impl FooStatics { | |
unsafe fn init() { |
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::cast; | |
use std::unstable::raw; | |
struct Mutable; | |
struct Immutable; | |
struct Foobar<'t, Mutability> { | |
/* priv */ ptr: raw::Slice<u8> | |
} |
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(macro_rules)]; | |
// Shorthand for state-machine actions. | |
macro_rules! one ( | |
( inc ) => ( self.counter += 1; ); | |
( print ) => ( println!("counter is {:d}", self.counter); ); | |
) | |
// A DSL for sequencing shorthand actions. | |
macro_rules! go ( |
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
extern crate serialize; | |
use serialize::json; | |
fn main() { | |
println!("{:?}", json::from_str("\"\\ud83d\\udca9\"")); | |
} |
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
macro_rules! test_eq( ($name:ident, $left:expr, $right:expr) => ( | |
#[test] | |
fn $name() { | |
assert_eq!($left, $right); | |
} | |
)) |
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
#!/usr/bin/perl -w | |
use strict; | |
sub shuffle { | |
my @new; | |
while(scalar(@_) > 0) { | |
push @new, (splice @_, rand(scalar(@_)), 1); | |
} | |
return @new; |
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 ctx = z3::Context::new(); | |
let x = ctx.new_bool(); | |
let y = ctx.new_bool(); | |
let demorgan = (!(x & y)).iff(!x | !y); | |
ctx.assert(demorgan); | |
println!("{:?}", ctx.check()); // => Some(true) |
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(asm, macro_rules)]; | |
extern crate test; | |
use test::BenchHarness; | |
static whitespace: &'static [u8] = bytes!("\r\n\t \0 "); | |
#[inline(never)] | |
fn has_space_sse(s: &str) -> bool { |
OlderNewer