Re:Thoughts on Rust, a few thousand lines in
by StavrosK on Wednesday January 09, 2019 @09:20PM
(#18870991)
What does zero-cost mean in this context? It must cost something to run, no? Or is it basically a compiler hint instructing the next function to treat the data as pure bytes?
[ Parent
| on HN ]
Re:Thoughts on Rust, a few thousand lines in
by burntsushi on Wednesday January 09, 2019 @09:28PM
(#18871029)
In this particular context, you can think of going from a `&str` to a `&[u8]` via `string.as_bytes()` as a safe cast. The in-memory representation remains the same, and the function call will almost certainly be inlined because its implementation is trivial.