enums3 feedback

Aperta
#2,127 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
content

Direzione di ricerca

Inizia dall’esercizio enums3 e dal test esistente, in particolare dal percorso state.process() menzionato nel report. Controlla come le istruzioni match illustrano attualmente il pattern matching, quindi determina quali modifiche sono necessarie all’esercizio e al test per verificare che i valori vengano passati e chiarire le indicazioni sulla denominazione e sulla sintassi dei pattern.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A-exercises C-enhancement

You can "cheese" enums3 by putting the test's desired values in the match statements:

        match message {
            Message::Resize { width, height } => self.resize(10, 30),
            Message::ChangeColor(red, green, blue) => self.change_color(255, 0, 255),
            Message::Quit => self.quit(),
            Message::Move(Point) => self.move_position(Point),
            Message::Echo(String) => self.echo(String),
        }

This passes the test, albeit with a bunch of warnings about how the variables are unused.
Maybe add a second pass test to make sure the values are being passed through from state.process()?

I also found that I had absolutely no idea why I would be using "r, g, b" over "red, green, blue" when these are not technically defined by me. Is this some function of structs/enums? Is it part of a standard library? Is it specific to rgb?

Also, maybe this exercise should take further advantage of match patterns? If the exercise's purpose is to teach match pattern syntax, I think maybe it should show off exhaustive match patterns as well. (Or maybe there should just be an entire exercise folder dedicated to match patterns, because this throws several new concepts at you at once.)

Hopefully I am not wasting time with this issue, I just found this exercise really confusing.

Lingua principale
Rust
Stelle
64.6k
Fork
11.3k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

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 rust-lang/rustlings

Tutte le issue di rust-lang/rustlings

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.