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
//! Generators in Rust, simulated at great expense using threads | |
//! | |
//! Here's a generator which yields the numbers from one to three: | |
//! | |
//! let gen = generate(|(), out| { | |
//! for i in 1..4 { | |
//! out.yield_(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
/* barriers.h --- interface to memory and code translation barriers */ | |
#ifndef MN__GC_BARRIERS_H | |
#define MN__GC_BARRIERS_H | |
/* The following two functions provide the memory-coherence behavior | |
of mutexes, but without any blocking or communication. | |
On many modern multi-threaded systems, one thread may see writes to |
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
5828: 49 83 fa ff cmp $0xffffffffffffffff,%r10 | |
582c: 74 5d je 588b <_ZN8triangle4main17h1e5682daf508becbE+0x11b> | |
582e: 49 8d 42 ff lea -0x1(%r10),%rax | |
5832: 49 f7 e2 mul %r10 | |
5835: 49 89 c0 mov %rax,%r8 | |
5838: 49 89 d1 mov %rdx,%r9 | |
583b: 49 8d 72 fe lea -0x2(%r10),%rsi | |
583f: 48 f7 e6 mul %rsi | |
5842: 48 89 c7 mov %rax,%rdi | |
5845: 48 89 d3 mov %rdx,%rbx |
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
5830: 48 8d 47 ff lea -0x1(%rdi),%rax | |
5834: 48 f7 e7 mul %rdi | |
5837: 48 89 c1 mov %rax,%rcx | |
583a: 48 89 d6 mov %rdx,%rsi | |
583d: 48 8d 5f fe lea -0x2(%rdi),%rbx | |
5841: 48 f7 e3 mul %rbx | |
5844: 0f af de imul %esi,%ebx | |
5847: 48 0f a4 ce 3f shld $0x3f,%rcx,%rsi | |
584c: 48 8d 0c 76 lea (%rsi,%rsi,2),%rcx | |
5850: 01 da add %ebx,%edx |
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
5826: xor %ecx,%ecx | |
5828: cmp $0xffffffffffffffff,%rsi | |
582c: je 5840 | |
582e: lea -0x1(%rsi),%rax | |
5832: mul %rsi | |
5835: mov %rdx,%rcx | |
5838: shld $0x3f,%rax,%rcx | |
583d: add %rsi,%rcx | |
5840: ... use %rcx |
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
(defun jimb-rust-clean-error () | |
"Clean up an error message from rustc to fit nicely in the book. | |
Run this command with point on the first line of an error message | |
copied from rustc and pasted into a Markdown file; we'll clean it | |
up and indent it as a code block." | |
(interactive) | |
(save-excursion | |
(forward-line 0) | |
(let ((top (point))) | |
(let ((line-was-interesting t) |
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 partition<T: Ord>(a: &mut[T]) -> usize { | |
assert!(a.len() >= 2); | |
let mut pivot = 0; | |
let (mut i, mut j) = (0, a.len()); | |
loop { | |
loop { | |
j -= 1; | |
if a[j] <= a[pivot] { break; } |
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
mod implicit_deref { | |
use std::ops::Deref; | |
struct T(i32); | |
struct S<'a>(&'a T); | |
impl<'a> Deref for S<'a> { | |
type Target = T; | |
fn deref(&self) -> &T { &self.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 std::str::FromStr; | |
use std::fmt::Debug; | |
use std::io::stdin; | |
use std::io::stdout; | |
use std::io::Write; | |
trait Game : Clone { | |
type Move : Copy + FromStr; | |
fn start() -> Self; | |
fn moves(&self) -> Vec<Self::Move>; |
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
@ changeset: 252017 47888f3efe7c Thu Mar 19 15:39:53 2015 -0700 | |
| bookmarks: mozalloc2 | |
| summary: wip | |
| phase: draft | |
| | |
o changeset: 252016 9c583c9b4d2d Thu Mar 19 01:03:05 2015 -0700 | |
| bookmarks: mozalloc-no-xpcom-config | |
| summary: Bug 1145051: Don't include xpcom-config.h from mozalloc.h; it's unused. | |
| phase: draft | |
| |