Hacker News new | ask | show | jobs
by baq 2051 days ago
I quite liked the tongue-in-cheek style.

> The book really led me to believe there are literally two types of strings in Rust

Oh you sweet summer child :) The joys of discovering that on lower levels, a String is not a str is an OsStr but is not a str and why that is are coming back to me.

Also, I particularly like the periodic table of rust types:

https://cosmic.mearie.org/2014/01/periodic-table-of-rust-typ...

This compared to almost any other language should tell you that Rust trades compilation speed for strictness and execution speed. It's really helpful to understand what you need to care about if you don't have a garbage collector working for you.

1 comments

Rust has String, OsString, PathBuf, CString and Vec<u8> plus their borrowed equivalents. And the borrowed versions are often wrapped in `&`, `&mut`, `Cow` or `Box`.

So many options in the standard library alone. There are several popular crates which add even more string/buffer types.

And the cool thing is that thanks to borrowing and traits like Deref and Display, most of these types have a zero-cost common denominator in `&str` or `&[u8]` which makes them reasonably interoperable.