Skip to content

Instantly share code, notes, and snippets.

struct TextRun {
priv text: @~str,
priv slice: &str,
priv glyphs: ~[Glyph],
priv size_: Size2D<au>,
priv min_break_width_: au,
let mut m = ~LinearMap();
m.insert(1, 2);
m.insert(2, 4);
// Freeze it
let m = move m;
// Thaw it
let mut m = move m;
let mut c = configure(o);
let home = c.root;
let first_time = os::path_exists(&home.push("sources.json"));
if !first_time && o.free[1] != ~"init" {
cmd_init(&c);
// FIXME (#2662): shouldn't need to reconfigure
c = configure(o);
fn spawn<T: Send>(val: T, f: extern fn(T)) {
f(val);
}
fn f(+i: int) {
assert i == 100;
}
@brson
brson / gist:3765332
Created September 22, 2012 06:16
rust-lang.org fix
fn main() {
for ["Alice", "Bob", "Carol"].each |name| {
let name = *name;
do task::spawn {
let v = rand::Rng().shuffle([1, 2, 3]);
for v.each |num| {
io::print(fmt!("%s says: '%d'\n", name, *num))
}
}
}
brian@axis:~/dev/rust-repl$ ./repl
rust> io::println("hi");
<anon>:3:39: 3:40 error: No rules expected the token ;
<anon>:3 io::println(fmt!("%?",io::println("hi");));
^
rust: task failed at 'explicit failure', /home/brian/dev/rust2/src/libsyntax/diagnostic.rs:52
rust> io::println("hi")
<anon>:1:0: 1:0 error: can't find crate for `core`
<anon>:1 extern mod std;
^
match self.buckets[idx] {
Some(Bucket {value: move value, _}) => {Some(value)}
None => fail ~"LinearMap::find: internal logic error"
}
/home/banderson/Dev/rust/src/libcore/send_map.rs:336:44: 336:55 error: cannot bind by-move when matching an lvalue
/home/banderson/Dev/rust/src/libcore/send_map.rs:336 Some(Bucket {value: move value, _}) => {Some(value)}
@brson
brson / gist:3830731
Created October 4, 2012 00:15
Draft Rust 0.4 release notes
Mozilla and the Rust community are entirely tickled to announce
version 0.4 of the Rust compiler and associated tools.
This release focuses on stabilizing as much of the language syntax as
possible, fully integrating borrowed pointers, and removing argument
modes. The brief release notes are included in this announcement, and
there is further explanation in the detailed release [notes] on the
wiki. Documentation and all the links in this email are available on
the [website]. As always, version 0.4 should be considered an alpha
release, suitable for early adopters and language enthusiasts. Please
extern mod std;
use core::pipes;
use std::cell::Cell;
fn bla(from_parent: pipes::Port<~str>, to_parent: pipes::Chan<~str>) {
do task::spawn {
to_parent.send(~"works?");
from_parent.try_recv();
}
}
@brson
brson / gist:3841957
Created October 5, 2012 19:49
Rust 0.4 contributors
alexrp
Andrew Paseltiner
auREAX
Ben Blum
Benjamin Peterson
Ben Striegel
Brian Anderson
Brian J. Burg
Chris Peterson
Damian Gryski