Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Accessing tuple elements using dot notation

Aperta
#80 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nrc/r4cppp

Tutte le issue di nrc/r4cppp

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.