Interesting habit I’ve formed when working with C APIs in Rust: When there’s a (pointer, length) pair somewhere in an API, I immediately convert it into a Rust slice with `slice::from_raw_parts()` and use that instead of doing pointer arithmetic with `ptr::offset`.
Go slices are…weird. They have an extra “capacity” field which makes them sort of array-ish.
-
-
Capacity has a few uses, but most useful one is that when slice = append(slice, val) is in a loop, append can grow the underlying allocated memory by doubling the capacity, while only 1 is added to the length.
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.