Skip to content

Instantly share code, notes, and snippets.

@sfackler
sfackler / cmp.rs
Last active August 29, 2015 14:02 — forked from alexcrichton/cmp.rs
pub trait Eq {
fn eq(&self, other: &Self) -> bool;
}
// equality operators are wired to this trait
#[lang = "partial_eq"]
pub trait PartialEq {
fn eq(&self, other: &Self) -> bool;
fn ne(&self, other: &Self) -> bool;
}
#[feature(macro_rules)];
use spec::test;
#[macro_escape]
mod spec {
macro_rules! my_macro (
() => (println!("hello"));
)
#[feature(macro_rules)];
use spec::test;
use spec::my_macro;
#[feature(macro_escape)]
mod spec {
#[macro_export]
macro_rules! my_macro (
() => (println!("hello"));
@sfackler
sfackler / gist:8271819
Last active January 2, 2016 07:39 — forked from krdln/gist:8271696
use std::util;
enum List {
Cons(int, ~List),
Nil
}
impl List {
fn prepend(&mut self, x : int) {
let new = ~util::replace(self, Nil);
*self = Cons(x, new);
pub trait ApplicationDelegate {
fn application_did_quit(&mut self, _timestamp: u32) {}
}
pub struct MouseMotionEventInfo;
pub struct MouseButtonEventInfo;
pub struct MouseWheelEventInfo;
pub trait MouseDelegate {
fn mouse_did_move(&mut self, _info: &MouseMotionEventInfo) {}