Why access subtyping is not allowed in type extensions?

I know the difference, I don't see how that's relevant here though. Traits can't have fields so your second example doesn't make sense (unless you are proposing an extension to Rust). Currently, if you wanted to access a field you would need to use a function like fn field(&self) -> &FieldType. Of course this runs into issues with the borrow checker because it can't see disjoint borrows across function boundaries.

(this issue can be alleviated with some sort of partial borrows)

Partial borrows have a long history, going back to 2016 on these forums

2 Likes