Accessing tuple elements using dot notation
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 58/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- rust
- Ambito
- documentation
Direzione di ricerca
Start in the "Data Types" and "Tuple structs" sections of the tutorial and verify how tuple and tuple-struct elements are described. Update the tuple-struct wording to mention dot notation and retain or add the relevant examples; done means the tutorial accurately documents both destructuring and indexed access.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In the "Data Types" section, a way of accessing the elements of a tuple discussed in this tutorial is through destructuring. Under "Tuple structs", it is suggested that this is the only way of accessing tuple elements:
Their fields must be accessed by destructuring (like a tuple), rather than by name.
However, there is another way of accessing tuple elements: through "dot notation". Tuple elements can be accessed directly by using a period (.) followed by the index of the value. For example:
fn bar(x: (i32, i32)) {
println!("x was ({}, {})", x.0, x.1); // Note the `x.0` and `x.1`.
}
This can also be applied to tuple structs:
struct IntPoint (i32, i32);
fn foo(x: IntPoint) {
println!("x was ({}, {})", x.0, x.1); // Note the `x.0` and `x.1`.
}
It is quite intriguing to me as to why this is left out, because this syntax is encountered early on in the Rust Programming Language book.
- Lingua principale
- Rust
- Stelle
- 3.9k
- Fork
- 297
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nrc/r4cppp
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
-
make_unique call typoAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
-
Problem with "primitives.md"Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 38/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 42/100
Issue simili
-
docs(openclaw): RTK_REWRITE_HOST relaxes every default ask, not only commands no rule matchedApertaarea:docs documentation good first issue priority:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
rtk-ai/rtk#4500 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
triage:accepted
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
open-telemetry/otel-arrow#4343 ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mishraprafful/multihull#150 ·
I maintainer di solito rispondono entro 1 giorno
-
`npx --package=vite-plus vp create` fails with exit 127 when npm is the chosen package managerApertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
voidzero-dev/vite-plus#2970 ·
I maintainer di solito rispondono entro 1 giorno
-
ai_p2 comp-parquet-reader-v3
Difficoltà 2/5 Mezza giornata Idoneità per principianti 66/100
ClickHouse/ClickHouse#124986 ·
I maintainer di solito rispondono entro 1 giorno