One thing I don't like about Rust is how taking a slice of a string can cause a runtime panic if the start or end of the slice ends up intersecting a multi-byte UTF-8 char. I would prefer it if this feature didn't exist at all rather than cause runtime panics. https://play.rust-lang.org/?gist=e02ce5e9aacfee3a2b4917d5624...
Thoughts on Rust, a few thousand lines in
31–40 of 183 posts
Re: Thoughts on Rust, a few thousand lines in
#32I've not done any rust dev before but the whole variable shadowing thing really scares me, in that it makes it not obvious where the initial declaration comes from. This seems difficult to reason about.
I've done a fair bit of rust development and never found that to be an issue. It probably helps that the only ways to introduce new variables are all very distinctive: let [new variables] = [expr]; if/while let [new variables] = [expr] { [new variables scoped here] } for [new variables] in expr { [new variables scoped here] } fn name([new_variables]) { [new variables scoped here] }
Re: Thoughts on Rust, a few thousand lines in
#33One thing I don't like about Rust is how taking a slice of a string can cause a runtime panic if the start or end of the slice ends up intersecting a multi-byte UTF-8 char. I would prefer it if this feature didn't exist at all rather than cause runtime panics. https://play.rust-lang.org/?gist=e02ce5e9aacfee3a2b4917d5624...
Re: Thoughts on Rust, a few thousand lines in
#34Rust is great, and I highly recommend learning Rust if you want to become a better C++ developer. C++ introduces a lot of unnecessary headaches Rust completely solves. Rust is worth the switch if only because reading error messages from expanded templates is horrible compared to type system that actually understands type parameters.
I'm really bullish on Rust becoming even more mainstream, to the point anyone can pick it up and use it in their business without a second thought by 2020.
Re: Thoughts on Rust, a few thousand lines in
#35One thing I don't like about Rust is how taking a slice of a string can cause a runtime panic if the start or end of the slice ends up intersecting a multi-byte UTF-8 char. I would prefer it if this feature didn't exist at all rather than cause runtime panics. https://play.rust-lang.org/?gist=e02ce5e9aacfee3a2b4917d5624...
Does this bug exist because it would be too expensive to check every string before slicing? (Being Rust-ignorant), can you not type a binary as UTF-8? Are there 2 versions of string functions, fast ones that assume ASCII and slow ones that assume UTF-8?
String always assumes full UTF-8. You could make an AsciiString type if you wanted, but it's not provided by the standard library.
Re: Thoughts on Rust, a few thousand lines in
#36Earlier quoted context omitted.
You can't mutate variables in rust without declaring mut
But how do you know just by reading that code? It would not be obvious to me at all.
Re: Thoughts on Rust, a few thousand lines in
#37> Like Go, Rust can compile statically linked linux binaries. The GNU C library (needed not only by C programs for C things) doesn't support static linking, so the only way this is possible is to use another library entirely, or raw inlined syscalls (where applicable).
$ rustup target add x86_64-unknown-linux-musl
$ cargo build --target x86_64-unknown-linux-musl
away.Re: Thoughts on Rust, a few thousand lines in
#38One thing I don't like about Rust is how taking a slice of a string can cause a runtime panic if the start or end of the slice ends up intersecting a multi-byte UTF-8 char. I would prefer it if this feature didn't exist at all rather than cause runtime panics. https://play.rust-lang.org/?gist=e02ce5e9aacfee3a2b4917d5624...
Does this bug exist because it would be too expensive to check every string before slicing? (Being Rust-ignorant), can you not type a binary as UTF-8? Are there 2 versions of string functions, fast ones that assume ASCII and slow ones that assume UTF-8?
Re: Thoughts on Rust, a few thousand lines in
#39Earlier quoted context omitted.
I've done a fair bit of rust development and never found that to be an issue. It probably helps that the only ways to introduce new variables are all very distinctive: let [new variables] = [expr]; if/while let [new variables] = [expr] { [new variables scoped here] } for [new variables] in expr { [new variables scoped here] } fn name([new_variables]) { [new variables scoped here] }
You forgot `match` and closures. But in general I think new variables can be created in all contexts where a pattern can be used.
Re: Thoughts on Rust, a few thousand lines in
#40One thing I don't like about Rust is how taking a slice of a string can cause a runtime panic if the start or end of the slice ends up intersecting a multi-byte UTF-8 char. I would prefer it if this feature didn't exist at all rather than cause runtime panics. https://play.rust-lang.org/?gist=e02ce5e9aacfee3a2b4917d5624...
e.g. my_hashmap["foo"] will panic at runtime if the key "foo" is not present, or return the associated value if it is. But my_hashmap.get("foo") will return None if "foo" is not present and Some(value) if it is.