Skip to content

Instantly share code, notes, and snippets.

@SiegeLord
SiegeLord / play.rs
Created September 14, 2015 04:30 — forked from ooooak/play.rs
#[derive(Debug)]
enum Lx {
Str(String),
Int(String),
Keyword(String),
LxUnk(char),
}
fn main() {
#[macro_export]
macro_rules! mat
{
( $($($e: expr),+);+ ) =>
{
Matrix::new(&[$(
&[$(
($e) as f64,
)+],
)+])
@SiegeLord
SiegeLord / kwargs.rs
Created September 16, 2014 16:56
Keyword arguments!
#![feature(phase)]
#[phase(plugin)]
extern crate kwarg_macros;
kwarg_decl!(foo(a = 1, b = 2, c = 3))
fn foo(a: int, b: int, c: int) -> (int, int, int)
{
(a, b, c)
@SiegeLord
SiegeLord / bench
Created September 1, 2014 12:19
Escaped string
test count_bench ... bench: 16566 ns/iter (+/- 307)
test lower_bench ... bench: 16149 ns/iter (+/- 581)
@SiegeLord
SiegeLord / error.rs
Created August 18, 2014 17:38
Operator overloads
#![feature(globs, phase, macro_rules)]
extern crate algebloat;
#[phase(plugin)]
extern crate algebloat_macros;
use algebloat::*;
fn add<
T: MatrixRawGet + SameShape + MatrixShape + Clone +
@SiegeLord
SiegeLord / test.rs
Last active August 29, 2015 14:04
custom_operators
operator_rules! my_awesome_operators
{
unary($b ^) : right(5) =>
{
$a.fact()
},
trinary($a ^ $b : $c) =>
{
if $a { $b } else { $c }
}
$ ldd a.out
linux-vdso.so.1 => (0x00007fff1fa00000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff720fc8000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff7213c0000)
@SiegeLord
SiegeLord / output
Created June 11, 2014 15:54
Rust matrix expression templates
clone
Matrix { data: [100, 200, 300] }
@SiegeLord
SiegeLord / output
Created June 11, 2014 11:53
Rust matrix moving via refcell
clone
move
move
[100, 200, 300]
@SiegeLord
SiegeLord / output
Last active August 29, 2015 14:02
C++ matrix moving
clone
move
move
100 200 300