4 ms·
(for newcomers) nothing works out of the box or as expected program[0]="+"; | ^^^^^^^^^^ the type `str` cannot be mutably indexed by `{integer}` error:
by singularity2001 9y ago
(for newcomers) nothing works out of the box or as expected
program[0]="+";
| ^^^^^^^^^^ the type `str` cannot be mutably indexed by `{integer}`
error: use of unstable library feature 'collections': needs investigation to see if to_string() can match perf
error: borrowed value does not live long enough
reference must be valid for the block suffix following statement 0
When you use an index operator ([]) you get the actual object at index location. You do not get a reference, pointer or copy.
cannot move out of indexed content
- killercup 9y agoPlease reformat your comment so it's more readable. Adding 4 spaces in front of a line will make it monospace.
- marcosdumay 9y agoOuch. I still couldn't wrap my mind to that string traversing gets intuitive in Rust. The entire iterator thing seems completely counter-intuitive.
- smaddox 9y agoIsn't it basically the same in Go?
- marcosdumay 9y agoI don't know Go, so I can't really tell.
- pornel 9y agoRust is especially difficult if you bring your C-like assumptions to it. You first need to learn difference between a borrow (a view, which may be read-only) and owned type, and know that Rust enforces stdlib strings to be UTF-8. Random mutation of a byte in a string is possible, but it has been deliberately put behind an unsafe function call, and there are better alternatives available (like char iterators). It's not hard once you "get" the way Rust works with data.
- alkonaut 9y ago> Rust is especially difficult if you bring your C-like assumptions to it. To be fair it's very difficult if you bring your JS/Python/C#/Java assumptions there too. As a lifelong Java/C# dev, I just never imagined having objects on the stack. In C# knowing what goes on the stack is important - but the thing with everything stack is that it's copied - so it's basically just trivial values that sit on the stack. In Rust and C++ you can make entire complex applications whose data is entirely on the stack. And getting over that treshold is a big mental barrier. I'm used to just thinking of my app state as a blob on the heap. A functional programmer or a C++ programmer thinks differently.