Hacker News new | ask | show | jobs
by meltyness 452 days ago
Yeah I think this is "Deref coercion" in Rust.[0]

For example since Vec can Deref to Slice, you can syntactically run Slice methods on a Vec; meaning Vec is a subtype of Slice.

[0] https://doc.rust-lang.org/std/ops/trait.Deref.html#deref-coe...

1 comments

As I revisit, this also comes up more explicitly when dealing with lifetimes as a type, and stacked borrows.

[0] https://doc.rust-lang.org/nomicon/subtyping.html

Lifetimes are the only subtyping relationship in Rust, yes.