I do exactly the same in Go when working with C (ptr,len): unsafe cast to a ridiculously large array then immediately to a slice with capacity==len. It makes the arithmetic far clearer.
-
-
-
You lost me at "unsafe cast to a ridiculously large array". Go doesn't have a concept of a slice independent from an array?
- 2 more replies
New conversation -
-
-
Except the need to check the nullability all the time before that :(
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I've wanted to take this one step farther, when I have control of the C APIs - have a standard (pointer, length) pattern and a Rust macro that automatically maches it and converts to slices.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Slices are one of the best things in Rust, so why would you not, really.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I'm happy that C++ seems to be getting std::span.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Interesting habit I formed using Ruby's FFI: scan the preprocessed header files. But wave goodbye to portability.
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.