|
|
|
|
|
by throwaway8948
1596 days ago
|
|
>It should be simple, right? Well, no. If you want to have memory safe subset, you absolutely cannot initialize structs with random bag of bytes in general case. C let's you cut corners here, but in Rust you need to implement (de)serializing logic (no need for unsafe). >Then I learned that structs are not laid out as declared (OMG!), etc.
>It should be simple! I tried to create a variadic function and you can guess how it went. This is only surprising if you have this weird assumption that things should work like they do in C + some extra. |
|
Hmm. Well that sucks. It might be slower than reading into a struct directly (does more IO calls, there is more code to execute, probably uses more memory). My focus is on embedded applications, so "the less, the better".
> no need for unsafe
Can you point out an example on reading a bunch of structs from a file? Without std? Now I'm really curious.
> you have this weird assumption
You are probably right. I intended to use Rust in embedded as I said before so I thought a system language like Rust could fit. But you are right and the more I read (docs and comments like yours) I realize it's not C, and Rust may require extra steps and resources to achieve the same things I can do in C. With consequential hit on performance/code size/whatever, that it's a thing to consider seriously in constrained environments.