-
I am converting some OCaml code to Rust.
-
I am representing OCaml list as a Rust Vec (with end = front of list).
-
I see OCaml patterns like:
f(nil) -> ...
f(a :: nil) -> ...
f(a :: b) -> ...
Is there a nice way to match this in Rust ? Rust match works well for destructuring enums, but I want to use a Vec instead of mimicking OCaml lists via
pub enum FakeList<T> {
Nil,
Cons(T, Rc<FakeList<T>>)
}
EDIT: don't want -> want; i.e. I want to use Vec, I don't want to mimic FakeList