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
fn backtrack<'a, T>(&self, a: &'a [T], b: &'a [T], i: usize, j: usize) -> Vec<&'a T> | |
where T: Eq { | |
if i == 0 || j == 0 { | |
vec![] | |
} else if a[i] == b[j] { | |
let mut prefix_lcs = self.backtrack(a, b, i - 1, j - 1); | |
prefix_lcs.push(&a[i]); | |
prefix_lcs |
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::io::{self, Read, Write}; | |
use std::net::Shutdown; | |
use hyper::net::{HttpConnector, NetworkConnector, HttpStream}; | |
fn fetch_http(host: &str, port: u16, scheme: &str, data: &[u8]) -> io::Result<Vec<u8>> { | |
let mut connector = HttpConnector(None); | |
let mut stream = connector.connect(host, port, scheme).unwrap(); | |
println!("{:?}", stream); |
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
Compiling net_replayer v0.0.1 (file:///Users/ulyssecarion/rust/net_replayer) | |
src/lib.rs:4:1: 4:5 src/lib.rs:4:1: 4:5 error: error: expected item, found `asdf` | |
expected item, found `asdf`src/lib.rs | |
:4 asdf-- | |
src/lib.rs:4 asdf-- | |
^~~~ | |
^~~~ | |
Build failed, waiting for other jobs to finish... | |
Could not compile `net_replayer`. |
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
test tokenize lipsum-zh.html size 1024 ... bench: 3563 ns/iter (+/- 65) | |
test tokenize lipsum-zh.html size 1048576 ... bench: 4229471 ns/iter (+/- 344137) | |
test tokenize lipsum.html size 1024 ... bench: 1580 ns/iter (+/- 26) | |
test tokenize lipsum.html size 1048576 ... bench: 2463919 ns/iter (+/- 331551) | |
test tokenize lipsum.html size 1048576 (clone only) ... bench: 257680 ns/iter (+/- 12418) | |
test tokenize medium-fragment.html ... bench: 80507 ns/iter (+/- 1004) | |
test tokenize small-fragment.html ... bench: 7614 ns/iter (+/- 2761) | |
test tokenize strong.html size 1024 ... bench: 52213 ns/iter (+/- 9796) | |
test tokenize strong.html size 1048576 ... bench: 55531397 ns/iter (+/- 34521875) | |
test tokenize tiny-fragment.html ... bench: 1347 ns/iter (+/- 265) |
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
$ multirust override nightly-2015-03-20 | |
multirust: installing toolchain 'nightly-2015-03-20' | |
multirust: downloading rust manifest for 'nightly-2015-03-20' | |
multirust: downloading 'https://static.rust-lang.org/dist/2015-03-20/channel-rust-nightly.sha256' to '/Users/ulyssecarion/.multirust/tmp/tmp-18723-1' | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0curl: (22) The requested URL returned error: 404 Not Found | |
multirust: couldn't download checksum file 'https://static.rust-lang.org/dist/2015-03-20/channel-rust-nightly.sha256' |
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 flate2; | |
use std::old_io::{BufferedReader, File}; | |
use flate2::reader::ZlibDecoder; | |
#[test] | |
fn test() { | |
let path = ".git/objects/c3/05bbc0533de6c05e73f37280d31667c5514169"; | |
let file = File::open(&Path::new(path)); | |
let mut reader = BufferedReader::new(file); |
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
pub fn read_file(path: &str) -> IoResult<String> { | |
let basepath = Path::new(".git"); | |
File::open(&basepath.join(path)).read_to_string() | |
} | |
pub enum HeadState { | |
Detached(String), | |
Attached(String) | |
} |
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
#![feature(slicing_syntax)] | |
use std::collections::RingBuf; | |
fn main() { | |
let xs = &[1i, 2i, 3i, 4i, 5i]; | |
let mut iter = EachCons { iter: xs.iter(), n: 3, buffer: RingBuf::new() }; | |
for x in iter { | |
println!("{}", x); |
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
/Users/ulyssecarion/rust/sparsile/src/lib.rs:7:9: 13:10 error: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:7 State { | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:8 runState: |firstState| { | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:9 let (result, nextState) = (self.runState)(firstState); | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:10 | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:11 (f(result).runState)(nextState) | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:12 } | |
... | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:6:65: 14:6 note: first, the lifetime cannot outlive the block at 6:64... | |
/Users/ulyssecarion/rust/sparsile/src/lib.rs:6 fn and_then<B>(&self, f: |A| -> State<S, B>) -> State<S, B> { |
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
$ cowsay -f telebears 'Go bears!' | |
___________ | |
< Go bears! > | |
----------- | |
\ _ | |
\ (_) <-- TeleBEARS | |
\ ^__^ / \ | |
\ (oo)\_____/_\ \ | |
(__)\ you ) / | |
||----w (( |