Skip to content

Instantly share code, notes, and snippets.

type circular_buf<T> = {start: uint,
end: uint,
buf: [mut T]
};
fn make_circle<T>(s: uint, e: uint, +b: [mut T]) -> circular_buf<T> {
ret {start: s, end: e, buf: b };
}
fn main() { }
fn main() {
// Bitvector to represent sets of integral types
type int_ty_set = uint;
impl methods for int_ty_set {
fn union(s: int_ty_set) -> int_ty_set { self | s }
fn intersection(s: int_ty_set) -> int_ty_set { self & s }
lkuper@lenny:~/rust/build$ export RUST_LOG=rustc::middle::typeck::infer=3,::rt::backtrace
lkuper@lenny:~/rust/build$ make check
cfg: shell host triple x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: unix-y environment
cfg: using gcc
cfg: no pandoc found, omitting doc/rust.pdf
cfg: no llnextgen found, omitting grammar-verification
cfg: no pandoc found, omitting library doc build
cfg: including dist rules
rust-try:
#!/bin/bash
git diff --quiet HEAD
if [[ "$?" != "0" ]]; then
echo "Cannot push to try with uncommitted changes."
exit 1
fi
git push -f mozilla HEAD:try
lkuper@lenny:~/rust/build$ make check-stage1-rpass VERBOSE=1 TESTNAME=deep-vector2 RUST_LOG=::rt::backtrace
cfg: shell host triple x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: unix-y environment
cfg: using gcc
cfg: no pandoc found, omitting doc/rust.pdf
cfg: no llnextgen found, omitting grammar-verification
cfg: no pandoc found, omitting library doc build
cfg: including dist rules
cfg: including test rules
iface addable { fn plus(n: int) -> int; }
iface subtractable { fn minus(n: int) -> int; }
impl of addable for int {
fn plus(n: int) -> int { self + n }
fn minus(n: int) -> int { self - n }
}
impl of subtractable for int {
fn minus(n: int) -> uint { self - n as uint }
// Instance coherence enforcement should forbid this situation
mod C1 {
trait C1Trait { }
}
mod C2 {
type C2Type = int;
}
iface from_string {
fn from_string(s: str) -> self;
}
impl of from_string for int {
fn from_string(s: str) -> int {
let o = int::from_str(s);
alt o {
some(i) { i }
none { fail; }
lkuper@lenny:~/rust/build$ make check
cfg: shell host triple x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: unix-y environment
cfg: using gcc
cfg: no pandoc found, omitting doc/rust.pdf
cfg: no llnextgen found, omitting grammar-verification
cfg: no pandoc found, omitting library doc build
cfg: including dist rules
cfg: including test rules
lkuper@lenny:~/rust/build$ make check
cfg: shell host triple x86_64-unknown-linux-gnu
cfg: host for x86_64-unknown-linux-gnu is x86_64
cfg: unix-y environment
cfg: using gcc
cfg: no pandoc found, omitting doc/rust.pdf
cfg: no llnextgen found, omitting grammar-verification
cfg: no pandoc found, omitting library doc build
cfg: including dist rules
cfg: including test rules