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
| #include <script/script_environment.hpp> | |
| #include <lua.hpp> | |
| #include <stdlib.h> | |
| #include <iostream> | |
| using namespace input; | |
| using namespace render; | |
| using namespace std; |
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 Context { | |
| index: uint | |
| } | |
| fn main () { | |
| let mut ctx = ~Context::new(); | |
| println!("test A"); | |
| ctx.snazzy_fn(|ctx_| { | |
| println!("start action index:{}", ctx_.index); | |
| ctx_.index += 1; |
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 p = Parent::new(~"pocket full of rain"); | |
| println!("Parent txt: {}", p.txt); | |
| } | |
| struct Parent<'a> { | |
| txt: ~str, | |
| data: ~ChildResult<'a> | |
| } |
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
| #[pkgid="github.com/brianheylin/edn#0.1"]; | |
| #[link(name="edn")]; | |
| #[desc = "An EDN parser"]; | |
| #[license = "BSD"]; | |
| #[crate_type = "lib"]; | |
| #[deriving(ToStr, Eq, Default)] | |
| pub struct Document { | |
| txt: ~str, | |
| ast: EDN |
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 default_int = |_: &str| { 0 }; | |
| let keys = ["keyA", "keyB"]; | |
| // what is the cost of creating a closure in a loop? | |
| for key in keys.iter() { | |
| let i = get_or_else(*key, |k: &str| { default_int(k) }); | |
| println!("i: {}", i); | |
| } |
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
| extern mod extra; | |
| use extra::treemap::TreeMap; | |
| type Hash = TreeMap<~str, ~str>; | |
| fn insert_hash(hash: &mut Hash) { | |
| let key = &~"key"; | |
| let find = || { |
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
| // main.rs:15:12: 15:16 error: cannot borrow `*hash` as mutable more than once at a time | |
| // main.rs:15 hash.insert(~"key", ~"value"); | |
| // ^~~~ | |
| // main.rs:11:10: 11:14 note: second borrow of `*hash` as mutable occurs here | |
| // main.rs:11 match hash.find_mut(key) { | |
| // ^~~~ | |
| extern mod extra; | |
| use extra::treemap::TreeMap; |
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
| static LBRACK: &'static char = &'['; | |
| static RBRACK: &'static char = &']'; | |
| fn main() { | |
| let ch = '['; | |
| let msg = match ch { | |
| RBRACK => "right", | |
| LBRACK => "left" |
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 Foo { | |
| child: Option<Foo> | |
| } | |
| fn main() { | |
| let foo = Foo { child: None }; | |
| info!("foo: %?", foo); | |
| } | |
| // >>> |
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
| rust|master ⇒ rust | |
| The rust tool is a convenience for managing rust source code. | |
| It acts as a shortcut for programs of the rust tool chain. | |
| Usage: rust <command> [arguments] | |
| The commands are: | |
| build compile rust source files | |
| run build an executable, and run it |
NewerOlder