you run the risk of leaking memory, or keeping a pointer that's been freed and so writing to it or freeing it later
-
-
Replying to @mountain_ghosts
so figuring out who "owns" what and what state everything is in *before* yielding to user code is crucial and easily broken
2 replies 0 retweets 1 like -
Replying to @mountain_ghosts
the first thing you learn when writing rust is how less rigorous you were than you thought.
2 replies 0 retweets 3 likes -
Replying to @wycats
I'm trying to arrange things so there's usually only one pointer to something in existence, which is tricky
2 replies 0 retweets 0 likes -
Replying to @mountain_ghosts @wycats
I have no idea if this corresponds to "ownership" (I don't know rust yet) so might be using the wrong words here
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts @wycats
but what I've heard about rust makes it sound like these are the sorts of problems it's designed to stop
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
"one pointer in existence" is ownership but it would be unacceptably unergonomic without borrowing.
1 reply 0 retweets 0 likes -
Replying to @wycats @mountain_ghosts
you can think of borrowing as "I give you ownership for the lifetime of your stack frame and you return it"
1 reply 0 retweets 0 likes -
Replying to @wycats @mountain_ghosts
but it just looks like fn foo(o: &Observer) and the semantics take care of the dance.
1 reply 0 retweets 0 likes -
Replying to @wycats
my situation is I'm giving data to a callee that might not return, and the data should be freed and un-referenced after use
2 replies 0 retweets 0 likes
that's just plain ownership in rust. fn foo(o: Observer) but you need to do the return dance (tuple, probably) yourself.
-
-
Replying to @wycats @mountain_ghosts
heh `(tuple, probably)` is a valid tuple.
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
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.