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
| impl SetupRequest: xio::IOable { | |
| static fn read<E: xio::Endian Copy>(_e: E, _buf: &_buf/[u8]) -> | |
| (SetupRequest, &_buf/[u8]) { | |
| { | |
| let (byte_order, _buf) = xio::IOable::read(_e, _buf); | |
| { | |
| let _buf = vec::view(_buf, 1, _buf.len()); | |
| { | |
| let (protocol_major_version, _buf) = | |
| xio::IOable::read(_e, _buf); |
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
| enum NewType<T> = T; | |
| struct UnAligned<T> { a: u8, b: T } | |
| fn main() { | |
| unsafe { | |
| let p: *UnAligned<u32> = ptr::null(); | |
| io::println(fmt!("%?", ptr::addr_of(&(*p).b) as uint)); | |
| } | |
| unsafe { | |
| let p: *UnAligned<NewType<u32>> = ptr::null(); |
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
| enum NewType<T> = T; | |
| struct AfterByte<T> { a: u8, b: T } | |
| const C0: AfterByte<u32> = AfterByte { a: 0xA5, b: 0xDEADBEEF }; | |
| const C1: AfterByte<NewType<u32>> = AfterByte { a: 0xA5, b: NewType(0xDEADBEEF) }; | |
| fn main() { | |
| io::println(fmt!("C0.b = %x", C0.b as uint)); | |
| io::println(fmt!("C1.b = %x", *(C1.b) as uint)); | |
| } |
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
| enum Option<T> { Some(T), None } | |
| fn gen_func<A>(...) { | |
| let o: Option<uint> = ...; | |
| match o { ... } | |
| } |
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 enum E { | |
| H = 0x7FFF_FFFF_FFFF_FFFF, | |
| L = 0x8000_0000_0000_0000 | |
| } | |
| pub fn f(e: E) -> bool { | |
| match e { | |
| H => true, | |
| L => false | |
| } |
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 S { x: int, y: int } | |
| fn effect(s: &str) -> S { io::println(s); S { x: 0, y: 0 } } | |
| pub fn main() { | |
| let _foo = S { x: 1, .. effect("this will be printed") }; | |
| let _ = S { x: 2, .. effect("and this won't") }; | |
| let _ = S { x: effect("but this will").y, .. effect("(still no)") }; | |
| } |
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 S { f0: ~str, f1: int } | |
| pub fn main() { | |
| let s = ~"Hello, world!"; | |
| let _s = S { f0: str::from_slice(s), ..S { f0: s, f1: 23 } }; | |
| io::println(_s.f0); | |
| } |
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 S { f0: ~str, f1: ~str } | |
| fn main() { | |
| let s = ~"Hello, world!"; | |
| let _s = S { f1: str::from_slice(s), f0: s }; | |
| io::println(_s.f0); | |
| io::println(_s.f1); | |
| } |
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 S { x: int, y: int } | |
| fn main() { | |
| let w; | |
| let s = S { x: 1, y: 2 }; | |
| let _ = S { x: 3, ..({ w = "World"; s }) }; | |
| io::println(fmt!("Hello, %s!", w)); | |
| } |
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
| #!/bin/sh | |
| thing() { | |
| local stem=$1 found=false | |
| for d in 1 2 3 4 5 6 7 8 9 | |
| do local p=$d$stem | |
| if [ $(factor $p | wc -w) -ne 2 ] | |
| then continue | |
| fi | |
| found=true | |
| thing $p || echo $p |