Rust beginner notes & questions

The sdl blog I linked above has a compelling, IMO, case. They were also able to work around it with refactoring. And I agree that with sufficient thought and ability to move code around it’s probably doable. But this requires a lot of foresight to get right in a public API, where you can’t easily make breaking changes. This virtually guarantees breaking change churn or users needing workarounds, likely at a performance cost.

The fact you can do disjoint borrows of fields is virtually essential for making Rust usable. The problem is, of course, you don’t want to expose fields in public APIs. And knowing which combination of fields callers will want to borrow, so you can do fn get(&mut self) -> (&mut i32, &mut i32) type of thing, is also not obvious in all cases. That’s a hard issue to reconcile.

2 Likes