This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: / |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Test<T> { | |
| a: T | |
| } | |
| pub fn test_int<'a>(a: &'a int) -> Test<&'a int> { | |
| Test { a: a } | |
| } | |
| fn main() { | |
| let a = 42; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub struct A { | |
| a: int | |
| } | |
| pub struct B { | |
| b: int | |
| } | |
| pub trait GetValue { | |
| fn get_value(&self) -> int; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub struct Test<'a> { | |
| function: 'a || | |
| } | |
| fn main() { | |
| let sayhello = || println!("Hello!"); | |
| let test = Test { function: sayhello }; | |
| (test.function)(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub struct Test<'a> { | |
| function: 'a || | |
| } | |
| fn main() { | |
| let mut parent = Test { function: || () }; | |
| { | |
| let x = 42; | |
| let sayhello = || println!("{}", x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn main() { | |
| let a: *int = &182323; | |
| let b: *int = &102932; | |
| let c = a as uint - b as uint; | |
| // Prints '16'. | |
| println!("{}", c); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! | |
| //! >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. |
OlderNewer