This file contains 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 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
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | |
// file at the top-level directory of this distribution and at | |
// http://rust-lang.org/COPYRIGHT. | |
// | |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
// option. This file may not be copied, modified, or distributed | |
// except according to those terms. |
This file contains 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
//! Monad macro in Rust | |
//! | |
//! A typical usage is to avoid nested match expressions. | |
//! | |
//! Supports: | |
//! - Pattern matching | |
//! - Or expressions (A | B => ...) | |
//! - Guarded statements (x if <cond> => ...) | |
#[feature(macro_rules)]; |
This file contains 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 crate collections; | |
use collections::hashmap::HashMap; | |
struct Node { | |
data : ~str, | |
children : ~HashMap<~str, Node>, | |
} | |
impl Node { | |
fn new(data: ~str) -> Node { |
This file contains 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
//! Chain macro in Rust | |
//! | |
//! A typical usage is to avoid nested match expressions. | |
//! | |
//! Supports: | |
//! - Pattern matching | |
//! - Or expressions (A | B => ...) | |
//! - Guarded statements (x if <cond> => ...) | |
//! - Implicit else (requires all arms to return same type) |
This file contains 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 crate collections; | |
use collections::TrieMap; | |
fn main() { | |
let workers = vec!( | |
("Jack", vec!((0000, 200), (500, 1200))), | |
("Jackie", vec!((0000, 600), (800, 1300))), | |
("Marty", vec!((400, 600), (1100, 1600), (1700, 2359))), | |
("Ronald", vec!((600, 1200), (1300, 1800), (1900, 2359))), |
This file contains 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
#![no_std] | |
extern crate rlibc; | |
pub fn foo(x: *mut u8, y: *u8) { | |
unsafe {rlibc::memcpy(x, y, 1);} | |
} |
This file contains 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::any::{Any,AnyRefExt}; | |
trait Object { | |
fn as_any<'a>(&'a self) -> &'a Any { | |
self as &Any | |
} | |
} | |
impl Object for uint {} | |
impl Object for &'static str {} |
This file contains 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
Compiling with --cfg idx_reverse --opt-level=3 | |
Samples: 27K of event 'cycles', Event count (approx.): 18709445305 | |
39.57% fannkuchredux fannkuchredux [.] fannkuch::h3c886b0c9fd4152cYda | |
37.13% fannkuchredux fannkuchredux [.] reverse::h8a92c2595b4c13ffaca | |
11.71% fannkuchredux fannkuchredux [.] next_permutation::h0b3a5cb57aef64bcdba | |
7.96% fannkuchredux fannkuchredux [.] rotate::ha766464a328f18a5Kaa | |
3.40% fannkuchredux fannkuchredux [.] vec::Vec$LT$T$GT$::push_all::h9473677268961327811 | |
0.01% fannkuchredux [kernel.kallsyms] [k] native_write_msr_safe |
This file contains 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::io::process::{Command, InheritFd}; | |
fn main() { | |
Command::new("rustc").arg("--version=verbose").stdout(InheritFd(1)).spawn().unwrap(); | |
} |
OlderNewer