Skip to content

Instantly share code, notes, and snippets.

Sven Nilsen bvssvni

Block or report user

Report or block bvssvni

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8853985
mkdir -p lib
rustc --out-dir=lib --link-args="-lglfw3 -lrt -lXrandr -lXi -lGL -lm -ldl -lXrender -ldrm -lXdamage -lX11-xcb -lxcb-glx -lXxf86vm -lXfixes -lXext -lX11 -lpthread -lxcb -lXau -lXdmcp " -O src/lib/lib.rs
error: linking with `cc` failed: exit code: 1
note: cc arguments: '-m64' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'lib/libglfw-rs-c68009f4-0.1.so' 'lib/glfw-rs.o' 'lib/glfw-rs.metadata.o' '-Wl,--as-needed' '-Wl,-O1' '-L/home/sven/Desktop/opensource/glfw-rs/.rust' '-L/home/sven/Desktop/opensource/glfw-rs' '-L/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lstd-966edb7e-0.10-pre' '-ldl' '-lm' '-lpthread' '-shared' '-lmorestack' '-Wl,-rpath,$ORIGIN/../../../../../../usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lglfw3' '-lrt' '-lXrandr' '-lXi' '-lGL' '-lm' '-ldl' '-lXrender' '-ldrm' '-lXdamage' '-lX11-xcb' '-lxcb-glx' '-lXxf86vm' '-lXfixes' '-lXext' '-lX11' '-lpthread' '-lxcb' '-lXau' '-lXdmcp'
note: /
View gist:8969541
struct Test<T> {
a: T
}
pub fn test_int<'a>(a: &'a int) -> Test<&'a int> {
Test { a: a }
}
fn main() {
let a = 42;
View gist:9147636
glfw::set_error_callback(~ErrorContext);
glfw::start(proc() {
let monitor = glfw::Monitor::get_primary().unwrap();
let window_mode = glfw::FullScreen(monitor);
let (w, h) = (1024, 768); // monitor.get_physical_size();
let window = glfw::Window::create(w as u32, h as u32, "Hello this is window", window_mode)
.expect("Failed to create GLFW window.");
window.set_key_polling(true);
View gist:9168032
pub struct A {
a: int
}
pub struct B {
b: int
}
pub trait GetValue {
fn get_value(&self) -> int;
View gist:9264409
pub struct Test<'a> {
function: 'a ||
}
fn main() {
let sayhello = || println!("Hello!");
let test = Test { function: sayhello };
(test.function)();
}
View gist:9264437
pub struct Test<'a> {
function: 'a ||
}
fn main() {
// x outlives 'test.function' because of lifetime constraint.
let x = 42;
let sayhello = || println!("{}", x);
let test = Test { function: sayhello };
View gist:9264525
pub struct Test<'a> {
function: 'a ||
}
fn main() {
let mut parent = Test { function: || () };
{
let x = 42;
let sayhello = || println!("{}", x);
@bvssvni
bvssvni / gist:9304940
Last active Aug 29, 2015
A simple stack based evaluator
View gist:9304940
//! A simple stack based evaluator.
//! You can modify this code to create your own domain specific language.
//!
//! Terminology:
//! - A 'stack' here is represented as a vector.
//! - The 'top' of the stack means the end of the vector.
//!
//! In this example we will create a language that evaluates:
//!
//! Point3D
@bvssvni
bvssvni / gist:9327294
Last active Aug 29, 2015
Emulating dynamic types: How to implement Any for owned Trait pointers
View gist:9327294
//!
//! >rustc --version
//! rustc 0.10-pre (ee8f45e 2014-02-18 13:41:49 -0800)
//!
//! In this example we will implement Any for a trait pointer.
//! This is useful when we want to design an Entity/Component system
//! that is extensible beyond the library.
//!
//! As example we have two objects 'Player' and 'Enemy'.
//! Both implement the trait 'Entity' which is used 90% of the time.
View gist:9319361
fn main() {
let a: *int = &182323;
let b: *int = &102932;
let c = a as uint - b as uint;
// Prints '16'.
println!("{}", c);
}
You can’t perform that action at this time.