Skip to content

Instantly share code, notes, and snippets.

View drbawb's full-sized avatar

Robbie Straw drbawb

View GitHub Profile
@drbawb
drbawb / main.rs
Created March 29, 2013 15:35
rust snippet -- playing w/ MutexARC
extern mod std;
use core::io::*;
use std::timer::*;
struct Dog {
mut name : ~str
}
fn lol() -> int {
@drbawb
drbawb / bark.rs
Created April 1, 2013 21:52
Iterating over Traits causes segfault on Linux! (rust 0.6)
extern mod std;
struct Dog {
name : ~str
}
trait Barks {
fn bark(&self) -> ~str;
}
--summary--
--KOEO SELF TEST--
118 O,C Coolant Temp (EdT) Sensor circuit above maximum voitage/ -40 F
113 O,C Air Charge Temp (ACT) Sensor circuit above maximum voltagE/ -40 F
327 O,R,C EVP circuit below minimum voltage
--CONTINUOUS MEMORY--
113 O,C Air Charge Temp (ACT) Sensor circuit above maximum voltagE/ -40 F
118 O,C Coolant Temp (EdT) Sensor circuit above maximum voitage/ -40 F
157 C Mass Air Flow (MAE) Sensor circuit below minimum voltage
158 O,C Mass Air Flow (MAE) Sensor circuit above maximum voltage
use std::f64;
static TILE_SIZE: i32 = 32;
pub struct Game(f64);
pub struct Pixel(i32);
pub struct Tile(uint);
pub struct Frame(uint);
trait AsGame {fn to_game(&self) -> Game;}
@drbawb
drbawb / main.rs
Last active August 29, 2015 13:56
pub mod units;
/// A main() outside the module does not work, #to_pixel() not in scope?
fn main() {
let mut gs: units::Game = units::Game(640.0) * units::Game(480.0);
println!("gs->pix, outside mod: {:?}", gs.to_pixel());
}
use std::f64;
static TILE_SIZE: i32 = 32;
pub struct Game(f64);
pub struct Pixel(i32);
pub struct Tile(uint);
pub struct Frame(uint);
pub trait AsGame {fn to_game(&self) -> Game;}
@drbawb
drbawb / locks.rs
Last active August 29, 2015 14:03
Data Race Example
use std::io::timer::sleep;
use std::sync::{Arc,RWLock};
fn main() {
println!("running channels: ");
channels();
println!("running locks: ");
locks();
}
[package]
name = "sdl-timer-ex"
version = "0.0.1"
[dependencies]
sdl2 = "*"
failures:
---- audio::test::test_audio_cvt stdout ----
thread 'audio::test::test_audio_cvt' panicked at 'assertion failed: `(left == right) && (right == left)`
---
LEFT:
`[0u8, 0u8, 0u8, 0u8, 1u8, 1u8, 1u8, 1u8, 2u8, 2u8, 0u8, 0u8, 3u8, 3u8, 1u8, 1u8, 4u8, 4u8, 0u8, 0u8, 5u8, 5u8, 1u8, 1u8, 6u8, 6u8, 0u8, 0u8, 7u8, 7u8, 1u8, 1u8, 8u8, 8u8, 0u8, 0u8, 9u8, 9u8, 1u8, 1u8, 10u8, 10u8, 0u8, 0u8, 11u8, 11u8, 1u8, 1u8, 12u8, 12u8, 0u8, 0u8, 13u8, 13u8, 1u8, 1u8, 14u8, 14u8, 0u8, 0u8, 15u8, 15u8, 1u8, 1u8, 16u8, 16u8, 0u8, 0u8, 17u8, 17u8, 1u8, 1u8, 18u8, 18u8, 0u8, 0u8, 19u8, 19u8, 1u8, 1u8, 20u8, 20u8, 0u8, 0u8, 21u8, 21u8, 1u8, 1u8, 22u8, 22u8, 0u8, 0u8, 23u8, 23u8, 1u8, 1u8, 24u8, 24u8, 0u8, 0u8, 25u8, 25u8, 1u8, 1u8, 26u8, 26u8, 0u8, 0u8, 27u8, 27u8, 1u8, 1u8, 28u8, 28u8, 0u8, 0u8, 29u8, 29u8, 1u8, 1u8, 30u8, 30u8, 0u8, 0u8, 31u8, 31u8, 1u8, 1u8, 32u8, 32u8, 0u8, 0u8, 33u8, 33u8, 1u8, 1u8, 34u8, 34u8, 0u8, 0u8, 35u8, 35u8, 1u8, 1u8, 36u8, 36u8, 0u8, 0u8, 37u8, 37u8, 1u8, 1u8, 38u8, 38u8, 0u8, 0u8, 39u8, 39u8
@drbawb
drbawb / gist:96d2d59dc03e46e27bc4
Created January 13, 2015 22:39
use of moved value
/home/drbawb/projects/piper/kyrie/src/world/services.rs:128:33: 128:41 error: use of moved value: `pub_sock`
/home/drbawb/projects/piper/kyrie/src/world/services.rs:128 let peer = ServicePeer::new(pub_sock, uid.clone());
^~~~~~~~
/home/drbawb/projects/piper/kyrie/src/world/services.rs:128:33: 128:41 note: `pub_sock` moved here because it has type `zmq::Socket`, which is non-copyable
/home/drbawb/projects/piper/kyrie/src/world/services.rs:128 let peer = ServicePeer::new(pub_sock, uid.clone());
^~~~~~~~