Skip to content

Instantly share code, notes, and snippets.

@shepmaster
shepmaster / hello.rs
Created September 22, 2014 00:54 — forked from bgamari/hello.rs
$ rustc hong.rs
hong.rs:34:20: 34:27 error: `cursors` does not live long enough
hong.rs:34 for cur in cursors.iter() {
^~~~~~~
hong.rs:26:68: 47:2 note: reference must be valid for the lifetime 'a as defined on the block at 26:67...
hong.rs:26 (dict: &'a SuffixTree<E>, mut iter: Iter) -> Vec<Match<'a, E>> {
hong.rs:27
hong.rs:28 let mut offset: uint = 0;
hong.rs:29 let mut cursors: Vec<Cursor<E>> = Vec::new();
hong.rs:30 let mut matches = Vec::new();
@shepmaster
shepmaster / README.md
Last active March 11, 2020 05:21 — forked from kelcecil/README.md
Implementation of binary search tree in OCaml and Rust (modeled after the OCaml solution).

Here's two implementations of a binary search tree in OCaml and Rust. The Rust version was written to deliberately look as close to the OCaml as possible (and it'd get pretty close if I used match instead of OCaml's variants). I'm pretty sure my OCaml implementation is idiomatic, and I'd like some advice on what steps I'd probably take to make the Rust example more idiomatic. My objective is to talk about how close the examples can be to each other as well as how different the examples can be (hopefully demonstrating strengths for both.)

Any other thoughts or ideas are also helpful and super appreciated!