Java has had this since Java7 and Go has had it since at least 1.13, so I'm not sure why he hasn't seen it based on his other experiences.
Rust from a Gopher – Lessons 3 and 4
11–20 of 27 posts
Re: Rust from a Gopher – Lessons 3 and 4
#12WHy in the rust code snippets do all the spaces show as up _ ? Oh, odd, it's my dark mode addon.
Re: Rust from a Gopher – Lessons 3 and 4
#13I 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…
Rust has String, OsString, PathBuf, CString and Vec 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.
Re: Rust from a Gopher – Lessons 3 and 4
#14> const MAX_POINTS: u32 = 100_000; // wtf is this ugly numeric shit Java has had this since Java7 and Go has had it since at least 1.13, so I'm not sure why he hasn't seen it based on his other experiences.
Re: Rust from a Gopher – Lessons 3 and 4
#15Re: Rust from a Gopher – Lessons 3 and 4
#16> const MAX_POINTS: u32 = 100_000; // wtf is this ugly numeric shit Java has had this since Java7 and Go has had it since at least 1.13, so I'm not sure why he hasn't seen it based on his other experiences.
Going through his code, all his numbers were in the form of 1,234,567 with coma place separators. The code worked somewhat purely by accident. It took a surprising amount of convincing on my part to have them understand that wasn’t a thing they could do in JavaScript.
Re: Rust from a Gopher – Lessons 3 and 4
#17The part complaining about missing details in the error message seems weird. You get a pretty detailed error even without using `--explain`: error[E0384]: cannot assign twice to immutable variable `x` --> src/main.rs:4:5 | 3 | let x = 3; | - | | | first assignment to `x` | help: make this binding mutable: `mut x` 4 | x = 5; | ^^^^^ cannot assign twice to immutable variable error: aborting due to previous error; 2 war…
I don’t quite understand the author‘s complaint either - the error message in the example (like most others) does state quite precisely what went wrong and how to fix it (By default, variables in Rust are immutable. To fix this error, add the keyword `mut` after the keyword `let` when declaring the variable.).
I wonder what the author is wishing for?
Re: Rust from a Gopher – Lessons 3 and 4
#18Not only might your run into some but trivial edge case complexity which add the user of the standard library you don't have to know about at all but you will also run into a bunch of unstable nightly and as such often but that well documented thinks, some of which might never get stabilized.
So if you start learning rust this can lead to unnecessary confusion.
Btw. one of the reasons I like rust is that for a lot of the (more hidden) complexity you get away without knowing it and (important) if you don't get away with it you run into a compiler error. Which is in difference to C++ where a bunch of the (more hidden) complexity has quite a high potential to screw you up if you run into it without knowing about it.
Re: Rust from a Gopher – Lessons 3 and 4
#19I 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…
Rust has String, OsString, PathBuf, CString and Vec 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.
Re: Rust from a Gopher – Lessons 3 and 4
#20Btw. there are parts in the standards library which are not suited for learning rust by understanding it. Not only might your run into some but trivial edge case complexity which add the user of the standard library you don't have to know about at all but you will also run into a bunch of unstable nightly and as such often but that well documented thinks, some of which might never get stabilized. So if you start lear…