Skip to content

Instantly share code, notes, and snippets.

macro_rules! ok (($T:ident) => ($T))
macro_rules! bad (($T:ty) => ($T))
ok!(int); // compiles
//bad!(int); // crashes
fn main() { }
oiseau:~/tryrust/src clements> rust run /tmp/foo.rs
/tmp/foo.rs:3:8: 3:9 error: expected item but found `;`
/tmp/foo.rs:3 ok!(int); // compiles
@jbclements
jbclements / fold-excerpt.rs
Created July 3, 2013 23:00
wait.. this seems totally pointless
pub fn make_fold(afp: ast_fold_fns) -> @ast_fold {
afp as @ast_fold
}
@jbclements
jbclements / mutation-and-testing.rkt
Created July 3, 2013 19:03
slides for a short talk on mutation and testing. Won't make much sense without the scripted talk. Also, you need to have light-bulb-changer.png.
#lang slideshow
(define machine-bitmap
(scale (bitmap "./light-bulb-changer.png")
0.75))
;; yikes! this code could use some serious cleanup. Sorry.
(define middle-rect-width 350)
(define middle-rect-height 350)
@jbclements
jbclements / recursive-definition.rs
Created July 2, 2013 17:35
recursive-definition
struct NonEmptyList {first: int, rest: MyList}
enum MyList {
endoflist,
listnode(@NonEmptyList)
}
@jbclements
jbclements / fold_traverses_macros.rs
Created June 6, 2013 18:55
I expect this to fail under existing versions of rust
macro_rules! fmt_with_13{
($x:expr) => (fmt!($x,13))
}
fn main() {
assert_eq!((fmt_with_13!("thirteen: %?")),~"thirteen: 13");
}
CFG_PREFIX := /usr/local
CFG_LOCAL_RUST_ROOT := /usr/local
CFG_LLVM_ROOT :=
CFG_BUILD_TRIPLE := x86_64-apple-darwin
CFG_HOST_TRIPLES := x86_64-apple-darwin
CFG_TARGET_TRIPLES := x86_64-apple-darwin
CFG_ANDROID_CROSS_PATH := /opt/ndk_standalone
CFG_MINGW32_CROSS_PATH :=
CFG_PERL := /usr/bin/perl
@jbclements
jbclements / gist:5715905
Created June 5, 2013 18:08
failed install
jclements-09740:~/rust/build clements> sudo make install
cfg: build triple x86_64-apple-darwin
cfg: host triples x86_64-apple-darwin
cfg: target triples x86_64-apple-darwin
Makefile:131: mk/platform.mk: No such file or directory
You need to run this command from the toplevel of the working tree.
Makefile:579: mk/target.mk: No such file or directory
Makefile:580: mk/host.mk: No such file or directory
Makefile:581: mk/stage0.mk: No such file or directory
Makefile:582: mk/rt.mk: No such file or directory
macro_rules! plant_id_in_inner_macro (
(($cuckoo:ident) =>
({macro_rules! inner_macro (
(($x:expr) =>
($x + $ $cuckoo))
)
inner_macro!(13)}))
)
plant_id_in_inner_macro!(x)
macro_rules! g (
() =>
({
macro_rules! f(($y:ident)=>
({
let $y=3;
$y
}));
f!(z)
}))
#lang racket
;; this file shows how you might build a command-line debugger. It doesn't provide much in
;; the way of convenience functions....
(provide (contract-out [run-program (-> path-string? void?)]
[continue (-> void?)]
[this-step (or/c false? step?)]
[srcloc (-> any)])
(struct-out step)