-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Compiler thinks variable needs to be mutable when getting an owned slice #46265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is correct - you aren't getting an owned slice, you're getting a |
You can also use |
@jonas-schievink but as far as I know, I getting an immutable slice. https://play.rust-lang.org/?gist=266b22ca7d45c52200c068fa34bb5b61&version=nightly
In the above code, And why does splitting it into 2 lines work? https://play.rust-lang.org/?gist=1600e7488b3de8e7ed489828af1c6727&version=nightly
The above code compiles, but all I've done is introduce an intermediate variable |
See https://doc.rust-lang.org/std/vec/struct.Vec.html#method.append |
The compiler is calling IndexMut here, and that's wrong. |
Ah, right, that's an actual bug, of course: #28935 |
Thanks both! This is a duplicate of #28935 and it seems like an exact match. |
https://play.rust-lang.org/?gist=be40620b431766ae921d89b3e2c0b9e5&version=nightly
The text was updated successfully, but these errors were encountered: