Hacker News new | ask | show | jobs
by needlesslygrim 651 days ago
I assume it's derived from the OCaml generic type syntax (the first Rust compiler was written in OCaml after all), for example the definition of the type `Option.t` in OCaml:

  type 'a t = 'a option = 
  | None
  | Some of 'a
I think this is the case because IIRC this function:

  fn slice<'a>(s: &'a str) -> &'a str { &s[0..2] }
Is generic over the lifetime of `s`, and it I assume it would have been difficult to distinguish generic types and lifetimes.
1 comments

It’s related yeah. In Ocaml it’s a generic, and in Rust, lifetimes are also a generic type.
Good to know, also cool that you replied!