News for hackers. Stuff that matters.
Re:Rust explained using easy English by pelliphant on Thursday July 23, 2020 @04:48AM (#23925434)
somewhat of a rust noob: but as I recall there is a difference between string and array of chars.

string use utf-8, which is 1 byte for the most common characters.

char is unicode

Re:Rust explained using easy English by ChrisSD on Thursday July 23, 2020 @05:10AM (#23925527)
They are both unicode. A `String` is unicode encoded as `UTF-8` whereas a `char` is simply a single, un-encoded, code point.

An array of `char` would technically be UTF-32. Which isn't particularly useful, imho.

Re:Rust explained using easy English by Tobu on Thursday July 23, 2020 @07:45AM (#23926290)
A char is a scalar value, rather: https://doc.rust-lang.org/std/primitive.char.html
Re:Rust explained using easy English by ChrisSD on Thursday July 23, 2020 @10:02AM (#23927441)
You're right, of course. Unicode terminology always trips me up. I have to remember that a scalar value is almost the same as a code point except that it excludes surrogates.
Re:Rust explained using easy English by pelliphant on Thursday July 23, 2020 @06:49AM (#23925974)
ok, thnx for clarifying.