Skip to content

Instantly share code, notes, and snippets.

@SiegeLord
SiegeLord / test.rs
Created April 13, 2014 17:57
Connection
struct Connection
{
active: *mut bool,
payload: *mut c_void,
callback: fn(*mut c_void),
}
impl Connection
{
pub fn new(payload: *mut c_void, callback: fn(*mut c_void)) -> (Connection, Connection)
test.rs:4:6: 4:30 error: unresolved import: there is no `BenchHarness` in `test::test`
test.rs:4 use self::test::BenchHarness;
^~~~~~~~~~~~~~~~~~~~~~~~
test.rs:4:6: 4:30 error: failed to resolve import `self::test::BenchHarness`
test.rs:4 use self::test::BenchHarness;
^~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to 2 previous errors
@SiegeLord
SiegeLord / components.rs
Created April 9, 2014 20:13
Component system 2
#![feature(macro_rules)]
struct Location
{
x: f32,
y: f32
}
struct Velocity
@SiegeLord
SiegeLord / test.rs
Created April 6, 2014 02:18
Double free
use std::cast;
use std::libc::{c_void, malloc, free};
struct A
{
a: *mut c_void
}
impl Drop for A
{
@SiegeLord
SiegeLord / errors
Created March 31, 2014 13:16
Mutex
test.rs:15:3: 15:4 error: cannot capture variable of type `proc(Test)`, which does not fulfill `Send`, in a bounded closure
test.rs:15 a(Test{ mutex: Arc::new(Mutex::new(())) } );
^
test.rs:15:3: 15:4 note: this closure's environment must satisfy `Send`
test.rs:15 a(Test{ mutex: Arc::new(Mutex::new(())) } );
let bmp = core.create_bitmap(256, 256);
match bmp
{
Some(b) => /* b is not NULL */,
None => /* b is NULL, but inaccessible */
}
@SiegeLord
SiegeLord / test.rs
Last active August 29, 2015 13:57
Arrays
struct MyArray<T>(~[T]);
trait Foo {}
struct A;
impl Foo for A {}
struct B;
impl Foo for B {}
@SiegeLord
SiegeLord / test.rs
Created March 8, 2014 00:41
More mutability
struct S<'l>
{
data: &'l [u8]
}
struct MS<'l>
{
data: &'l mut [u8]
}
@SiegeLord
SiegeLord / test.rs
Created March 8, 2014 00:28
Mutable hacks
struct S<T>
{
data: T
}
trait Mut<'l>
{
fn set(self, idx: uint, val: u8);
}
@SiegeLord
SiegeLord / test.rs
Created March 7, 2014 23:45
get/set
struct S;
trait Get
{
fn get(self);
}
trait Set
{
fn set(self);
}