Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tomjakubowski's full-sized avatar

Tom Jakubowski tomjakubowski

View GitHub Profile
@tomjakubowski
tomjakubowski / playground.rs
Created August 6, 2015 04:58 — forked from anonymous/playground.rs
Shared via Rust Playground
macro_rules! as_item {
($i:item) => {$i};
}
macro_rules! impl_partial_eq {
([$($lt:tt)*] $lhs:ty, $rhs:ty) => {
as_item! {
impl<$($lt)*> PartialEq<$rhs> for $lhs {
fn eq(&self, other: &$rhs) -> bool {
// common implementation of PartialEq goes here
From 1560a5eff8d8d9d24c42f5e41787bdbc5408d701 Mon Sep 17 00:00:00 2001
From: Tom Jakubowski <tom@crystae.net>
Date: Fri, 10 Jul 2015 17:11:54 -0700
Subject: [PATCH] Make it build on stable
---
src/main.rs | 2 --
src/models/player.rs | 17 +++++++++--------
2 files changed, 9 insertions(+), 10 deletions(-)
#![feature(on_unimplemented)]
trait TyEq<T> { }
#[rustc_on_unimplemented="{Self} is not type-equal to {T}"]
impl<T> TyEq<T> for T { }
fn static_assert_ty_eq<T: TyEq<U>, U>() { }
fn main(){
@tomjakubowski
tomjakubowski / Makefile
Last active November 13, 2015 17:30 — forked from japaric/Makefile
test:
rm -f liberoc.rlib
rustc eroc.rs
rustc -L . -C codegen_units=2 unicode.rs
#![crate_type="lib"]
pub use a::InnerPubExported;
pub trait RootPub{}
trait RootHidden{}
mod a {
pub trait InnerPubExported{}
pub trait InnerPubHidden{}
I think one realllly cool thing about github gists is that the non-adjustable input box is wider than the non-adjustable display box
#![feature(macro_rules)]
macro_rules! try_harder {
($e:expr) => {
match $e {
Ok(val) => val,
Err(e) => return Err(e)
}
};
($e:expr, $f:expr) => {
#!/usr/bin/ruby
# Convert a Markdown README to HTML with Github Flavored Markdown
# Github and Pygments styles are included in the output
#
# Requirements: json gem (`gem install json`)
#
# Input: STDIN or filename
# Output: STDOUT
# Arguments: "-c" to copy to clipboard (or "| pbcopy"), or "> filename.html" to output to a file
# cat README.md | flavor > README.html
trait Foo {
fn foo(_: Self) -> int {
42
}
}
struct Baz;
impl Foo for Baz { }
struct Bar { x: int }
fn sum_vec_int<T: Num + Zero>(xs: &[T]) -> T {
let zero: T = Zero::zero();
xs.iter().fold(zero, |x, y| { x + *y })
}
sum_vec_int([1.0, 2.0, 3.0].as_slice());