writing this in C should at least prepare me for modelling ownership in rust correctly
-
-
I'm trying to arrange things so there's usually only one pointer to something in existence, which is tricky
-
I have no idea if this corresponds to "ownership" (I don't know rust yet) so might be using the wrong words here
-
but what I've heard about rust makes it sound like these are the sorts of problems it's designed to stop
-
"one pointer in existence" is ownership but it would be unacceptably unergonomic without borrowing.
-
you can think of borrowing as "I give you ownership for the lifetime of your stack frame and you return it"
-
but it just looks like fn foo(o: &Observer) and the semantics take care of the dance.
-
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
-
which means some nasty interleaved copying and freeing in the *callee*, which feels horrible, maybe there's a better way
- 2 more replies
New conversation -
-
-
the first few weeks are being convinced the compiler is wrong and then realizing it's not.
Thanks. 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.