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 Struct_lua_Debug { | |
| event: c_int, | |
| name: *c_schar, | |
| namewhat: *c_schar, | |
| what: *c_schar, | |
| source: *c_schar, | |
| currentline: c_int, | |
| linedefined: c_int, | |
| lastlinedefined: c_int, | |
| nups: c_uchar, |
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
| /* automatically generated by rust-bindgen */ | |
| use libc::*; | |
| type Struct_lua_State = c_void; | |
| type lua_State = Struct_lua_State; | |
| type lua_CFunction = *u8; | |
| type lua_Reader = *u8; | |
| type lua_Writer = *u8; | |
| type lua_Alloc = *u8; | |
| type lua_Number = c_double; |
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 with<T, U, V>(foo: fn() -> U, bar: fn(U) -> V) { | |
| bar(foo()); | |
| } | |
| fn open() -> int { | |
| return 1; | |
| } | |
| fn main() { | |
| do with(open) |f| { |
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 mk_appender(suffix: ~str) -> fn@(~str) -> ~str { | |
| return fn@(s: ~str) -> ~str { s + suffix }; | |
| } | |
| fn main() { | |
| let shout = mk_appender(~"!"); | |
| io::println(shout(~"hey ho, let's go")); | |
| } |
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 mk_appender(suffix: ~str) -> @fn(~str) -> ~str { | |
| return @fn(s: ~str) -> ~str { s + suffix }; // error: mismatched types: expected `fn@(~str) -> ~str` but found `@fn&(~str) -> ~str` (expected fn but found @-ptr) | |
| } | |
| fn main() { | |
| let shout = mk_appender(~"!"); | |
| io::println(shout(~"hey ho, let's go")); | |
| } |
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
| const bar: int = 1, | |
| foo: int = 4; | |
| fn main() { | |
| let baz: int = 0, | |
| qux: int = 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 x = 1; | |
| let f = fn@() -> int { | |
| return x+20; | |
| }; | |
| let mut x = move x; | |
| io::println(f().to_str()); | |
| x += 1; | |
| io::println(f().to_str()); | |
| } |
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 Vec2 { | |
| x: f32, | |
| y: f32, | |
| } | |
| #[inline(always)] | |
| fn lerp(a: f32, b: f32, v: f32) -> f32 { | |
| a * (1f32 - v) + b * v | |
| } |
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
| match x { | |
| x < 0 => -1, | |
| x > 0 => 1, | |
| 0 | |
| } |
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
| use io::ReaderUtil; | |
| fn main () { | |
| let stdin = io::stdin(); | |
| let raw_input = stdin.read_line(); | |
| io::println(raw_input); | |
| } |