Destructuring pt2 - confusion about temporary variables created in match statements
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Documentazione
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- rust
- Ambito
- documentation
Direzione di ricerca
Start with the “Destructuring pt2” section and compare the second and third code snippets, especially option 1 in each match statement. Verify how dereferencing interacts with copy and move semantics, then clarify whether a temporary is created and whether the value is copied or moved; the work is done when both examples explain the behavior consistently.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
In Destructuring pt2, in the second code snippet, regarding the first option of the match statement, it says
"...in the first approach we dereference x to a temporary variable with type
Enum1(which copies the value inx)...".
Enum1 has copy semantics, so it makes sense that *x (the value in x) is copied into a temp variable. From that I conclude that if there is a match statement on a dereference of an object with copy semantics, a temporary variable is created and the value of *x is copied into it. So far so good.
However, in the third code snippet, option 1 of the match statement, where the value of x (now of type Enum2) has move semantics, shouldn't the same hold true, but this time, with a move operation, making this scenario illegal? That is, when creating a match statement on a dereference of an object with move semantics, it should, following the same logic, result in a temporary variable into which *x would be moved? Or does that not apply in case of object with move semantics? That is, if you have a match statements on a dereference of an object with move semantics, no temporary variable is created?
I don't know the answer as I'm just starting out with Rust and it gets me confused. I think this point should be clarified.
- Lingua principale
- Rust
- Stelle
- 3.9k
- Fork
- 298
- 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
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
swc-project/swc#12516 ·
I maintainer di solito rispondono entro 1 giorno
-
mls-rs-crypto-awslc: exact aws-lc-rs =1.16.3 pin blocks rustls security updateForse già presa @muscariello l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
[work-item] adam-adae-worsening-emergence: conform spec.yaml to the specification style contract (REQ-1280)Forse già presa @muse-yamaa-bot l’ha presa oggi. Apertawork-item
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Possible memory leak: message iterators from pactffi_pact_handle_get_*message_iter are never deletedAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
pact-foundation/pact-go#652 ·
I maintainer di solito rispondono entro 1 giorno