|
|
|
|
|
by loeg
1299 days ago
|
|
I found a few things a little difficult. First, the compiler is not actually as smart / accepting of valid borrow patterns as should abstractly be possible. Things like borrowing different subfields of a struct in different and nonconflicting ways to different subroutines. This got a lot better in recent memory with non-lexical lifetimes but I think is still a problem. Two: splitting mut borrows. It’s reasonable to take a mut borrow of some resource and divide it into two independent borrows of exclusive components. Think non-overlapping subarrays, or independent struct members. The language does not really provide this for you, but it is safe. (There are some APIs like this but last time I checked they didn’t cover all usecases.) Structs containing a borrow are just weird and annoying to work with. Lifetime parameterization everywhere is verbose and it’s difficult to determine where you’ve made a mistake. The syntax for describing lifetime relationships is non-obvious to me. |
|
This refers to[1]
used as but you can see that the inner logic is just a bit of pointer twiddling[2] [1]: https://doc.rust-lang.org/std/primitive.slice.html#method.sp...[2]: https://doc.rust-lang.org/src/core/slice/mod.rs.html#1641-16...