Skip to content

Instantly share code, notes, and snippets.

<core-macros>:17:32: 17:39 error: mismatched types: expected `~str` but found `&static/str` (str storage differs: expected ~ but found &static)
<core-macros>:17 let _: &~str = &($msg);
^~~~~~~
<core-macros>:13:4: 1:0 note: in expansion of die!
/home/brian/dev/rust/src/test/compile-fail/die-not-unique.rs:2:4: 2:17 note: expansion site
/home/brian/dev/rust/src/test/compile-fail/die-not-unique.rs:2:9: 2:15 error: mismatched types: expected `~str` but found `&static/str` (str storage differs: expected ~ but found &static)
/home/brian/dev/rust/src/test/compile-fail/die-not-unique.rs:2 die!("test"); //~ ERROR what
^~~~~~
<core-macros>:13:4: 1:0 note: in expansion of die!
/home/brian/dev/rust/src/test/compile-fail/die-not-unique.rs:2:4: 2:17 note: expansion site
Mozilla and the Rust community are pleased to announce version 0.5 of
the Rust compiler and associated tools.
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 usual, version 0.5 should be considered an alpha release,
suitable for early adopters and language enthusiasts. Please file [bugs].
[notes]: https://github.com/mozilla/rust/wiki/Doc-detailed-release-notes
pub trait Trig<T> {
pure fn sin(&self) -> T;
}
pub trait Angle<T>: Trig<T> {}
//type Trait<R> = Trig<R>;
type Trait<R> = Angle<R>;
pub fn sin<A:Trait<R>, R>(theta: &A) -> R { theta.sin() }
@brson
brson / gist:4650566
Last active December 11, 2015 19:48
The UI is nice.
Output is now in `~/.rustpkg`, not `./.rustpkg`, and I don't see an option to use the local directory. We made cargo use the current directory instead of the user's directory to be like npm and isolate projects from each other. I don't want my four Rust workspaces all competing over resources under `~/.rustpkg`, and I don't want to wipe out all my builds globally when something goes wrong in one project
Trying to run `hunter`:
* When I `rustpkg build` inside the `rustpkg-test2` directory I build a binary that ends up ... somewhere
* I tried to `rustpkg prefer hunter` but 'package not found'
* Then I `rustpkg install` and that did something different
* Then `rustpkg prefer hunter` and finally my binary moves to `~/.rustpkg/bin`
@brson
brson / gist:4719480
Last active December 20, 2015 12:54
Useful Rust runtime tasks
# Useful Rust runtime tasks
https://github.com/mozilla/rust/issues/4770 port pipes to pthreads
https://github.com/mozilla/rust/issues/4768 remove dec_weak_task
https://github.com/mozilla/rust/issues/4392 remove lazy scheduler initialization
https://github.com/mozilla/rust/issues/3309 redesign logging - convert to task/pipe-based Rust
https://github.com/mozilla/rust/issues/2044 extract all the stack management from rust_task
https://github.com/mozilla/rust/issues/3695 change behavior of out-of-stack errors (graydon may have this on a branch)
https://github.com/mozilla/rust/issues/3406 rewrite rust_start in rust
https://github.com/mozilla/rust/issues/4812 rewrite various helper functions in rust
@brson
brson / gist:4964868
Last active December 13, 2015 19:48
pub fn spawn(f: ~fn()) {
do task::task().sched_mode(task::PlatformThread).spawn {
use core::private::finally::Finally;
do (|| {
// task work goes here
}).finally {
// terminate runs *inside* the task
terminate();
}
}
@brson
brson / gist:4969164
Last active December 13, 2015 20:18

This is a prototype task scheduler, written in Rust, that is driven by an abstract event loop, along with the beginnings of an I/O interface for translating asynchronous I/O to synchronous I/O via scheduler context switches. It is part of issue #4419.

It is not ready to merge, but this is an opportunity to review and discuss.

While I am primarily interested in proving the integration of I/O with the scheduler, this is also written with a number of other goals in mind:

  • Replacing C++ code with Rust
  • Clean up stack management (#2044, #4479, #4480)
  • Supporting the work stealing algorithm (#3095)
  • Providing scheduling operations for different scenarios, some that avoid memory synchronization.
@brson
brson / gist:4974294
Last active December 13, 2015 20:59
Raw read numbers

A simple test of read performance, newsched (-O) vs. node. The server command is yes | netcat -v -v -l 127.0.0.1 2931.

node:

var net = require('net');
var total = 0;
var client = net.connect(2931,
                         function() {
                             console.log('connected');
pub struct VariantDoc {
desc: Option<~str>,
sig: Option<~str>
}
fn main() {
let variants = ~[
VariantDoc {
desc: None,
sig: None
@brson
brson / gist:5017388
Last active December 14, 2015 02:59

Both resume_task_from_queue and callback take &mut self

            fn run_scheduler_once() {
                do Scheduler::local |scheduler| {
                    if scheduler.resume_task_from_queue() {
                        // Ok, a task ran. Nice! We'll do it again later
                        scheduler.event_loop.callback(run_scheduler_once);
                    }
                }