Skip to content

Instantly share code, notes, and snippets.

View olsonjeffery's full-sized avatar
💭
:3

Jeff Olson olsonjeffery

💭
:3
View GitHub Profile
@olsonjeffery
olsonjeffery / code.rs
Created June 16, 2015 23:41
issue w/ gfx_parameters! and large arrays
gfx_parameters!( Uniforms {
// projection stuff
u_Model@ model: [[f32; 4]; 4],
u_View@ view: [[f32; 4]; 4],
u_Proj@ proj: [[f32; 4]; 4],
// texture data
t_CharMap@ char_map: [f32; 16384],
t_Tile@ tile: gfx::shade::TextureParam<R>,
});
pub fn print(v: &BigRational) -> ~str {
match v.is_integer() {
true => v.numer().to_str(),
false => {
let whole_val = v.numer() / *v.denom();
let remainder_val = v.numer() % *v.denom();
let denom_fl: f64 = FromStr::from_str(v.denom().to_str())
.expect("should be able to convert denom to float");
let remainder_fl: f64 = FromStr::from_str(remainder_val.to_str())
.expect("should be able to convert remainder to float");
fn fact(n: i64) -> i64 {
if n <= 1 { 1 }
else { n * fact(n-1) }
}
fn main() {
println!("fact 10: {}", fact(10));
println!("fact 100: {}", fact(100));
}
#[test]
fn an_if_test_that_returns_a_None_out_expr_should_run_the_conseq_branch() {
let mut env = Env::new(
Some(vec!(~"x")), Some(vec!(Atom(Integer(42)))),
None);
let in_expr = parse_str(~"(if (set! x 37) (quote conseq) (quote alt))");
let out_expr = {
let env_borrow = &mut env;
eval(in_expr, env_borrow).expect("should return an Expr")
};
@olsonjeffery
olsonjeffery / build spew
Last active August 29, 2015 14:01
issue w/ borrows within a loop
jeff@mbp:~/src/dungeongame (master)$ make
check: formatting
make -C p2d -f Makefile
check: formatting
rustc -L lib --opt-level=3 --out-dir lib -D warnings --dep-info .rust/p2dux.deps.mk src/p2dux/lib.rs
src/p2dux/view/mod.rs:61:29: 61:37 error: cannot borrow `*passives` as mutable more than once at a time
src/p2dux/view/mod.rs:61 for view in passives.mut_iter() {
^~~~~~~~
src/p2dux/view/mod.rs:71:67: 71:75 note: previous borrow of `*passives` occurs here; the mutable borrow prevents subsequent moves, borrows, or modification of
`*passives` until the borrow ends
@olsonjeffery
olsonjeffery / spew
Created March 14, 2014 19:52
build error wrt -lSDL2
^~~~~~~~~
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib' '-o' 'client' 'client.o' '-nodefaultlibs' '-Lp2d/lib' '-Llib' '-L/Users/jeff/src/dungeongame/.rust' '-L/Users/jeff/src/dungeongame' '-L/Users/jeff/src/.rust' '-L/Users/jeff/.rust' '-framework' 'SDL2' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/libstd-966edb7e-0.10-pre.rlib' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/libgreen-80d9e76a-0.10-pre.rlib' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/librustuv-09e0b925-0.10-pre.rlib' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/libnative-51515d1a-0.10-pre.rlib' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/libsync-7bf3a0fc-0.10-pre.rlib' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/libserialize-d01a48ca-0.10-pre.rlib' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/libcollections-6cc47867-0.10-pre.rlib' '/Users/jeff/lib/rustlib/x86_64-apple-darwin/lib/libgetopts-f2d8d0e7-0.10-pre
// will pull in libserialize here in stage1+
#[cfg(stage1, stage2, stage3)]
extern mod serialize = "serialize";
// reexport extra::serialize in stage0
#[cfg(stage0)]
pub mod serialize;
@olsonjeffery
olsonjeffery / code.rs
Created January 25, 2014 00:13
error error fun time
// the offending code:
pub fn populate_world(world: &mut World<Agent>) -> Uuid {
let zone_a_id = world.new_zone(24, setup_zone);
// ....
}
/*
the error:
src/client/hf/ux/mod.rs:20:19: 20:20 error: cannot infer an appropriate lifetime for automatic coercion due to conflicting requirements
src/client/hf/ux/mod.rs:20 world: w,
^
src/client/hf/ux/mod.rs:18:69: 23:5 note: first, the lifetime cannot outlive the lifetime &'a as defined on the block at 18:69...
src/client/hf/ux/mod.rs:18 pub fn new<'a>(w: &'a mut World, d: &'a GameDisplay) -> ZoneView {
src/client/hf/ux/mod.rs:19 ZoneView {
src/client/hf/ux/mod.rs:20 world: w,
src/client/hf/ux/mod.rs:21 display: d
src/client/hf/ux/mod.rs:22 }
src/client/hf/ux/mod.rs:23 }
drwxr-xr-x 3 daemon daemon 36864 Oct 31 04:37 files