Skip to content

Instantly share code, notes, and snippets.

var comm = new EasyComm();
var CMD_HOME = 3;
var CMD_TOPBALL = 6;
comm.addCommand(CMD_TOPBALL, EasyComm.VALUE_BOOL, function(onOrOff) {
if (onOrOff) {
turnOnIndicator();
} else {
turnOffIndicator();
}
struct Thing;
fn do_stuff<'a>(thing: &'a Thing) -> &'a fn() {
let cloned_thing = thing.clone();
|| {
let cloned_cloned_thing = cloned_thing.clone();
}
}
fn main() {}
struct Thing;
fn do_stuff<'a>(thing: &'a Thing) -> &'a fn() {
let cloned_thing = thing.clone();
|| {
let cloned_cloned_thing = cloned_thing.clone();
}
}
fn main() {}
use std::hashmap::HashMap;
enum Thing { Foo, Bar }
struct Context<'self> {
scope: HashMap<&'self str, Thing>,
parent: &'self Option<Context<'self>>
}
impl<'self> Context<'self> {
use std::os;
fn tokenize(raw: &str) -> ~[&str] {
let replaced: ~str = raw.replace("(", " ( ").replace(")", " ) ");
replaced.split_iter(' ').collect()
}
fn main() {
printfln!("%?", tokenize(os::args()[1]));
}
@jmgrosen
jmgrosen / stuff.rs
Last active December 20, 2015 01:49
main.rs:159:13: 196:5 error: capture of moved value: `chans`
main.rs:159 do task::spawn {
main.rs:160 let iotask = uv_global_loop::get();
main.rs:161 let localhost = net::ip::v4::parse_addr("127.0.0.1");
main.rs:162 println("um");
main.rs:163
main.rs:164 let listen_result = do net::tcp::listen(localhost, 7654, 1, &iotask,
...
main.rs:165:54: 195:9 note: `chans` moved into closure environment here because it has type `~fn:Send(extra::net::tcp::TcpNewConnection, std::comm::SharedChan<std::option::Option<extra::net::tcp::TcpErrData>>)`, which is non-copyable (perhaps you meant to use clone()?)
main.rs:165 |_| ()) |new_conn, kill_ch| {
gl/camera.rs:6:4: 6:9 error: unresolved import. maybe a missing `extern mod extra`?
gl/camera.rs:6 use extra::arc;
^~~~~
gl/camera.rs:6:4: 6:14 error: failed to resolve import `extra::arc`
gl/camera.rs:6 use extra::arc;
^~~~~~~~~~
error: aborting due to 2 previous errors
use std::vec;
struct IndexableThing;
impl Index<uint, ~str> for IndexableThing {
fn index(&self, rhs: &uint) -> ~str {
(*rhs).to_str()
}
}
struct Foo {
value: uint
}
impl Sub<Foo, Foo> for Foo {
fn sub(&self, rhs: &Foo) -> Foo {
Foo {value: self.value - rhs.value}
}
}
use std::libc::{size_t, c_long, c_void};
use std::vec;
use std::str;
enum CurlCode {
CURLE_OK = 0,
CURLE_UNSUPPORTED_PROTOCOL, /* 1 */
CURLE_FAILED_INIT, /* 2 */
CURLE_URL_MALFORMAT, /* 3 */