Skip to content

Instantly share code, notes, and snippets.

fn foo(...) -> Baz
where X: ..., Y... {
}
@reem
reem / header.rs
Created February 5, 2015 02:56
Simplified Headers
#![feature(core, alloc)]
use std::fmt;
use std::rc::Rc;
use std::any::{Any, TypeId};
use std::collections::HashMap;
use std::ops::Deref;
pub trait HeaderFormat: fmt::Debug + Any {
fn fmt_header(&self, &mut fmt::Formatter) -> fmt::Result;
pub fn lock(&self) -> Option<OnceMutexGuard<T>> {
match state.load(SeqCst) {
UNUSED => {
state.store(LOCKED, SeqCst);
Some(OnceMutexGuard::new(self))
},
// Other thread got here first or already locked.
// Either way, no lock.
_ => None
}
@reem
reem / gist
Created October 15, 2014 08:40
// omg
loop {
state = match (state, try_io!(stream.read_byte())) {
(MsStart, b'G') => {
println!("Matching G");
MsG
},
(MsStart, b'P') => MsP,
(MsStart, b'H') => MsH,
(MsStart, b'O') => MsO,
@reem
reem / x
Created October 11, 2014 08:13
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 8045u32}:atomic::AtomicPtr<T>::load, real_substs=Substs[types=[[sync::spsc_queue::Node<sync::comm::stream::Message<std::sync::task_pool::Msg<()>>>];[];[]], regions=erased], ref_id=None)
DEBUG:rustc::middle::trans::monomorphize: leaving monomorphic fn atomic::AtomicPtr<T>::load
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 5730u32}:cell::UnsafeCell<T>::get, real_substs=Substs[types=[[*mut sync::spsc_queue::Node<sync::comm::stream::Message<std::sync::task_pool::Msg<()>>>];[];[]], regions=erased], ref_id=None)
DEBUG:rustc::middle::trans::monomorphize: leaving monomorphic fn cell::UnsafeCell<T>::get
DEBUG:rustc::middle::trans::monomorphize: monomorphic_fn(fn_id=syntax::ast::DefId{krate: 0u32, node: 5730u32}:cell::UnsafeCell<T>::get, real_substs=Substs[types=[[*mut sync::spsc_queue::Node<sync::comm::stream::Message<std::sync::task_pool::Msg<()>>>];[];[]], regio
@reem
reem / x
Created October 11, 2014 08:03
impl Handler for fn(&mut Request) -> IronResult<Response> {
fn call(&self, req: &mut Request) -> IronResult<Response> {
(*self)(req)
}
fn catch(&self, _: &mut Request, err: IronError) -> (Response, IronResult<()>) {
(Response::status(status::InternalServerError), Err(err))
}
}
@reem
reem / gist
Created October 11, 2014 07:46
task 'rustc' failed at 'no entry found for key', /Users/rustbuild/src/rust-buildbot/slave/nightly-mac/build/src/libstd/collections/hashmap/map.rs:1093
stack backtrace:
1: 0x10dbc8d69 - rt::backtrace::imp::write::hd2d3b636c19898a59Kq
2: 0x10dbcc081 - failure::on_fail::h81686b612f31dab9N1q
3: 0x10de41e55 - unwind::begin_unwind_inner::h4e3cb6f9f8acbab0Lud
4: 0x10a7b3f4e - unwind::begin_unwind::h16369091900694436626
5: 0x10acd13c0 - middle::ty::type_contents::tc_ty::h4c2d0a81e4ff02285iF
6: 0x10acd0afc - middle::ty::type_contents::tc_ty::h4c2d0a81e4ff02285iF
7: 0x10aa586d6 - middle::ty::type_contents::h815b89d15b77d6d60hF
use std::str::{mod, SendStr, Slice, Owned};
use std::collections::hashmap::{HashMap, Entries, Occupied, Vacant};
use std::cell::UnsafeCell;
use std::sync;
use std::mem;
use std::io;
pub trait Marker {
@reem
reem / fail
Created October 7, 2014 11:44
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-o' '/Users/Jonathan/hackreactor/iron/target/404' '/Users/Jonathan/hackreactor/iron/target/404.o' '-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a' '-nodefaultlibs' '-fno-lto' '-Wl,-dead_strip' '/Users/Jonathan/hackreactor/iron/target/libiron-15fdf3e4240d3ccd.rlib' '/Users/Jonathan/hackreactor/iron/target/deps/libplugin-f845a6ab531c9346.rlib' '/Users/Jonathan/hackreactor/iron/target/deps/libreplace-map-d1de898a4eb569a5.rlib' '/Users/Jonathan/hackreactor/iron/target/deps/libphantom-da5bb593d3eb3a9e.rlib' '/Users/Jonathan/hackreactor/iron/target/deps/libtypemap-3fdac74be380d9e4.rlib' '-L' '/usr/local/lib/rustlib/x86_64-apple-darwin/lib' '-lnative-4e7c5e5c' '/Users/Jonathan/hackreactor/iron/target/deps/libcontent_type-b3fc4f01bc3dcbfb.rlib' '-L' '/Users/Jonathan/hackreactor/iron/target/deps' '-lgenerator-e170cac01c08bdc6' '/Users/Jonathan/hackreactor/iron/target/deps/
use std::str::{mod, SendStr, Slice, Owned};
use std::collections::hashmap::{HashMap, Entries, Occupied, Vacant};
use std::cell::UnsafeCell;
use std::sync;
use std::mem;
use std::io;
pub trait Marker {