|
|
|
|
|
by fusslo
957 days ago
|
|
yeah I think I just need to write some stuff to figure it out. I was mostly trying to figure a 1:1 comparison. For example, If I write a Feature Control module in c and in rust, using the same design, are outputs similar? seems like either no one has a good sense of that comparison, or it's a bad comparison and I don't understand why. What I'm trying to avoid is having a space-saving task be "rewrite rust module X in c to save code memory" |
|
https://github.com/rust-lang/rust/issues/46213
In general Rust chases a "zero cost abstraction" ethos, so a lot of the type system niceties have no code or memory cost because the heavy lifting is done at compile time, not run time. For instance using specific traits for each GPIO pin ensures you won't accidentally apply some meaning meant for another pin, but the compiler will compile it right down to integers anyhow.
Things like options (how Rust deals with "null" values) are enums and usually incur a one byte penalty, but in some cases they can be compiled down to no overhead at all.