Two neat explanations I've picked up from @stjepang:
- 'static lifetime means there's no borrows
- Unpin means there's no self-referential fields (which is a specific kind of borrow)
Has helped a lot when trying to reason about both!
-
Show this thread
-
There's definitely more nuance and depth to both features here, but I've found these explanations to help a lot with creating intuition. Which is a great starting point to start exploring the finer details later.
1 reply 0 retweets 2 likesShow this thread -
(Also I hope I got both these explanations right. Lol)
1 reply 0 retweets 0 likesShow this thread -
Replying to @yoshuawuyts
Processes have stacks, heaps, static data, and code. Normally lifetimes refer to a bound of stack frames: the actual data exists on a frame <= a ref 'static is anything that isn't on a stack frame at all: either on the heap or in the static region of the process's address space.
1 reply 0 retweets 0 likes -
Replying to @sadisticsystems @yoshuawuyts
'static things can be borrowed infinitely by anything on the stack, because the heap and static data live longer than any stack
2 replies 0 retweets 0 likes -
Replying to @sadisticsystems @yoshuawuyts
This is what everyone thinks but isn’t really quite right.. an i32 on the stack is ‘static, this is why “doesn’t have any borrows” is a better intuition
2 replies 0 retweets 3 likes -
Basically a type is ‘static if you can move it into a ‘static reference( e.g. by using a cell or box::leak). The values don’t *have* to be in static memory to meet this bound
2 replies 0 retweets 3 likes
I'm trying hard to come up with a joke involving "leaky abstractions" and "box::leak", but nothing's good yet.
-
-
Just don't.
1 reply 0 retweets 1 like -
Alright, I'll drop it.
1 reply 0 retweets 2 likes - 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.