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 modes_(&mut self, reg: u8, modecode: u8) -> AddressingMode { | |
match (reg, modecode) { | |
(2,0b00) => Direct, | |
(2,0b01) => Absolute(self.next_inst()), | |
(2,0b10) => Const(4), | |
(2,0b11) => Const(8), | |
(3,0b00) => Const(0), | |
(3,0b01) => Const(1), | |
(3,0b10) => Const(2), | |
(3,0b11) => Const(-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
while { | |
let x = foo(); | |
bar(x); | |
x != 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
macro_rules! report_diag ( | |
($f: tt, $name: tt, $msg: tt, $(arg: tt)*) => { { | |
reg_diag_msg!($name, $msg); | |
let msg = format!($msg, $($arg)*); | |
let msg = format!("{}: {}", stringify!($name), msg); | |
$f(msg); | |
} }; | |
($f: tt, $name: tt, $msg: tt) => { { | |
reg_diag_msg!($name, $msg); | |
let msg = format!("{}: {}", stringify!($name), $msg); |
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 ifV<'a, T>(rc : &str, star: &'a T) -> Option<&'a T> { | |
if (Path::new( rc )).exists() { | |
Some(star) | |
} else { | |
None | |
} | |
} |
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 --lib call.rs | |
rustc --lib other_sym.rs | |
rustc -L . main.rs | |
./main |
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 count_word_use<'a>(string: &'a str) -> HashMap<&'a str, int> { | |
let mut word_list = HashMap::new(); | |
for word in string.split_iter(' ') { | |
word_list.insert_or_update_with(word, 1, |k, v| { *v += 1; }); | |
} | |
word_list | |
} | |
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 std::cell::Cell; | |
use std::str; | |
use std::rt::io::{Writer, Listener}; | |
use std::rt::io::Reader; | |
use std::rt::io::net::tcp::TcpListener; | |
use std::rt::io::net::ip::{SocketAddr, Ipv4Addr}; | |
fn main() { | |
let port = match std::os::args() { |
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
trait A {} | |
fn foo<T: A>(_: &T) {} | |
struct B; | |
impl A for B {} | |
impl<'self> A for &'self A {} | |
fn main() { | |
let a = B; |
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 std::rt::io; | |
struct HttpResponse<'self> { | |
out: &'self mut io::Writer, | |
} | |
fn write_http_header(_: &mut &mut io::Writer) {} | |
// fn write_http_header<W: io::Writer>(_: &mut W) {} | |
impl<'self> HttpResponse<'self> { |
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 StrangeCountIterator { priv A(int), priv B(int) } | |
impl Iterator<int> for StrangeCountIterator { | |
fn next(&mut self) -> Option<int> { | |
match *self { | |
A(mut i) => { | |
i += 1; | |
*self = B(i) | |
return Some(i); | |
} |