Our great sponsors
-
Clippy
A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
I believe a rust zero sized array ([T; 0]) inside of a #[repr(C)] struct behaves the same way as in GCC (can’t find a reference for it, but this thread kinda implies it), outside of that you might be able to use #[repr(align(n))] to achieve the same thing. Rust also contains unsized types, which can only be accessed through a layer of indirection, most prominently dyn Trait which is used for dynamic dispatch and [T] which is a contiguous piece of memory, the pointer to which stores its length.
-
DIY-ing bitfields: Rust does have repr(C) for compatibility in layout with C/C++; but bitfields in particular aren't even compatible between compilers, platforms etc. even when just considering C so Rust's basic layout guarantees probably aren't enough in that regard and you do have to put in some work right now. You might find this https://github.com/rust-lang/rfcs/issues/314 potentially interesting / useful in that regard.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
Even if you put it into an unsafe block UB will still be UB. If you have UB anywhere your code could do literally anything (in the best case that means a crash or reordered instructions - but it could be anything) - if your code exhibit's UB in any way it's essentially not valid Rust code. Citing the glossary from the Unsafe Code Guidelines Reference (emphasis by me):
-
Because of this you should really read the Rustonomicon before you go anywhere near unsafe Rust: a lot of things can go very wrong very quickly.