-
Notifications
You must be signed in to change notification settings - Fork 13k
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
The Rust Guide should mention [0u, ..5] initializer syntax #16696
Comments
The guide is not intended to be comprehensive. It's intended to get you going. I left this out intentionally. |
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 3, 2024
…ykril fix: Goto definition for `deref_mut` Fixes rust-lang#16520 https://github.com/rust-lang/rust-analyzer/blob/a3236be9d7a8179ac4a997858138a4d6c260a451/crates/hir/src/source_analyzer.rs#L375-L393 As we can see from the above, current implementation routes all dereferencing prefix operations to `Deref::deref` implementation, not regarding mutabilities. https://github.com/rust-lang/rust-analyzer/blob/a3236be9d7a8179ac4a997858138a4d6c260a451/crates/hir-ty/src/infer/mutability.rs#L134-L151 Since we are resolving them already in mutability inferences, we can use those results for proper `deref` / `deref_mut` routing.
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 3, 2024
…ykril fix: Goto definition for `index_mut` Mostly same with rust-lang#16696. https://github.com/rust-lang/rust-analyzer/blob/0ac05c05271f31c43d31017cbd288e8737a0edb0/crates/hir-ty/src/infer/mutability.rs#L103-L133 Thankfully, we are doing similar method resolutions so we can use them like the mentioned PR. As there are only three `LangItem`s having `Mut` in there names; `FnMut`, `DerefMut` and `IndexMut`, I think that this is the last one 😄
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm trying to learn Rust, I'm trying to write a function to calculate the frequency of letters in a string. I figure I'll start with a mutable 256-element array initialised to zeroes and increment the correct field as I go along.
Reading the "Vectors" section of the Rust Guide, it tells me how to create a literal array:
...and even mentions the abbreviated syntax for the type of such an array:
...but it doesn't mention that there's an abbreviated syntax for initialising an array.
It's possible the Guide is not the right place for this information, but it also wasn't mentioned in Rust By Example. It is mentioned in the language Reference Manual, but that document isn't necessarily aimed at beginners, and I didn't find it until I'd asked in
#rust
, found out the answer, and then searched for it specifically.The text was updated successfully, but these errors were encountered: