News for hackers. Stuff that matters.
Re:Rust is Not so Hairy by carlmr on Tuesday June 19, 2018 @03:59AM (#17344580)
Once you understand the borrow checker and how you can do a lot of zero copy string processing after you read in a file you will see it's a bit more than being statically compiled.
Re:Rust is Not so Hairy by nevi-me on Tuesday June 19, 2018 @04:15AM (#17344652)
Do you have a brief example, or is it the normal "I am a str".to_string()? I still have a long way to go with learning how Rust works.

I've heard about zero-copy in C and C++, but don't have an idea of how it's implemented in practise.

Re:Rust is Not so Hairy by carlmr on Tuesday June 19, 2018 @04:46AM (#17344797)
Basically what you can do is, e.g. Reading in a file. Now you have a string containing all your file.

When you then write a parser you can write it so that it uses string slices pointing into your file buffer whenever it references any text from your file, instead of creating new strings.

As long as you don't need to modify anything you don't need to create any copies and the borrow checking compiler will ensure that you don't invalidate any part of your buffer.

For a lot of parsers string allocation is a big part of runtime performance.