Skip to content

Instantly share code, notes, and snippets.

@alexcrichton
alexcrichton / foo.rs
Created December 12, 2014 20:15 — forked from anonymous/foo.rs
extern crate test;
const TEXT: &'static str = "Hello World!";
const LONG_TEXT: &'static str = "
There are not many persons who know what wonders are opened to them in the
stories and visions of their youth; for when as children we listen and dream,
we think but half-formed thoughts, and when as men we try to remember, we are
dulled and prosaic with the poison of life. But some of us awake in the night
with strange phantasms of enchanted hills and gardens, of fountains that sing
in the sun, of golden cliffs overhanging murmuring seas, of plains that stretch
wut.rs:11:1: 23:2 error: type parameter `__S` must also appear as a type parameter of some type defined within this crate
wut.rs:11 impl <__S: ::serialize::Encoder> ::serialize::Encodable<__S> for Foo {
wut.rs:12 fn encode(&self, __arg_0: &mut __S)
wut.rs:13 -> ::std::result::Result<(), ::__S::Error> {
wut.rs:14 match *self {
wut.rs:15 Foo(ref __self_0_0) =>
wut.rs:16 __arg_0.emit_struct("Foo", 1u, |_e| {
...
wut.rs:11:1: 23:2 note: for a limited time, you can add `#![feature(old_orphan_check)]` to your crate to disable this rule
wut.rs:11 impl <__S: ::serialize::Encoder> ::serialize::Encodable<__S> for Foo {
#![allow(unstable)]
use std::io;
use std::iter::repeat;
use std::slice;
pub struct Cursor<T> {
pos: u64,
inner: T,
}
@alexcrichton
alexcrichton / foo.rs
Last active August 29, 2015 14:15 — forked from anonymous/foo.rs
#![feature(test, hash, rand, core)]
extern crate test;
macro_rules! benches {
($f:expr, $var:ident) => {
use std::iter::repeat;
#[bench]
fn str_small(b: &mut ::test::Bencher) {
let $var = "foo";
extern crate test;
use std::io::prelude::*;
use std::io;
use std::mem;
use std::cmp;
use std::slice;
struct MyBufWriter1<'a> {
buf: &'a mut [u8],
}
running 5 tests
test read_to_end_doesnt_expand_capacity_unless_necessary ... ignored
test read_to_end_1024 ... bench: 53 ns/iter (+/- 1)
test read_to_end_64k ... bench: 1776 ns/iter (+/- 27)
test read_to_end_normal_test ... bench: 7 ns/iter (+/- 1)
test read_to_end_small_test ... bench: 6 ns/iter (+/- 1)
test result: ok. 0 passed; 0 failed; 1 ignored; 4 measured
[package]
name = "aster"
version = "0.2.3"
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
license = "MIT/Apache-2.0"
description = "A libsyntax ast builder"
repository = "https://github.com/erickt/rust-aster"
[features]
default = ["syntex_syntax"]
@alexcrichton
alexcrichton / Makefile
Last active December 28, 2015 01:49 — forked from anonymous/Makefile
all: libfoo.dylib bar.c
clang bar.c -o bar -L. -lfoo -Wl,-rpath,`pwd`
libfoo.dylib: foo.rs
rustc --lib foo.rs -Z gen-crate-map
ln -nsf libfoo-*.dylib libfoo.dylib
@alexcrichton
alexcrichton / foo.ll
Created January 15, 2014 23:38 — forked from anonymous/foo.ll
@glob = internal global i64 4
define void @main() {
atomicrmw volatile xchg i64* @glob, i64 5 seq_cst
ret void
}