This file contains 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
(component | |
(core module $app | |
(func (export "run") (result i32) | |
i32.const 0 | |
) | |
) | |
(core instance $app (instantiate $app)) | |
(func $run (result (result)) (canon lift (core func $app "run"))) | |
This file contains 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
http://blog.burntsushi.net/rust-error-handling/ | |
http://hoverbear.org/2014/08/12/option-monads-in-rust/ | |
http://hoverbear.org/2015/05/02/a-journey-into-iterators/ | |
http://hoverbear.org/2015/07/10/reading-rust-function-signatures/ | |
https://manishearth.github.io/blog/2015/05/03/where-rust-really-shines/ | |
https://manishearth.github.io/blog/2015/05/17/the-problem-with-shared-mutability/ | |
https://manishearth.github.io/blog/2015/05/27/wrapper-types-in-rust-choosing-your-guarantees/ | |
https://manishearth.github.io/blog/2015/05/30/how-rust-achieves-thread-safety/ | |
https://huonw.github.io/blog/2015/05/finding-closure-in-rust/ | |
https://huonw.github.io/blog/2015/05/defaulting-to-thread-safety/ |
This file contains 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
extern crate "rustc-serialize" as rustc_serialize; | |
use rustc_serialize::json; | |
use rustc_serialize::Encodable; | |
use rustc_serialize::json::Encoder; | |
use std::io::IoError; | |
#[deriving(RustcEncodable)] | |
struct Data { | |
str: &'static str, |
This file contains 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
// old one | |
fn process_stat(str: &str) -> Option<Vec<u32>> { | |
match STAT_REGEX.captures(str) { | |
Some(captures) => { | |
let iter = captures.at(1).split(' '); | |
let vec = iter.map(|x: &str| { | |
from_str(x).unwrap() | |
}).collect(); | |
Some(vec) | |
} |
This file contains 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::collections::hashmap::HashMap; | |
use std::io::Acceptor; | |
use std::io::BufferedReader; | |
use std::io::Listener; | |
use std::io::TcpListener; | |
use std::sync::Arc; | |
use std::sync::RWLock; | |
fn main() { | |
let map = Arc::new(RWLock::new(HashMap::<String, String>::new())); |
This file contains 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
module ProcessAsset | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def process_asset(asset_name) | |
define_method :process do | |
send "#{asset_name}_file_name" | |
end |
This file contains 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
class Object | |
def tap(method =nil, *params, &block) | |
block.call(self) if block | |
self.send(method, *params) if method | |
self | |
end | |
end |
This file contains 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
class Object | |
def tap(method=nil, *params, &block) | |
raise ArgumentError, "supply either a block or a method name to send" if (method || block) && !(method && block) | |
block ||= proc { self.send method, *params } | |
super(&block) | |
end | |
end |