Borrow Checker e Lifetimes
cannot borrow `x` as mutable more than once at a time – Rust E0499
L'errore E0499 impedisce race condition a tempo di compilazione: in Rust è consentito un solo riferimento mutabile (&mut) attivo per volta verso una specifica risorsa di memoria.
Cosa significa questo errore?
L'errore E0499 impedisce race condition a tempo di compilazione: in Rust è consentito un solo riferimento mutabile (&mut) attivo per volta verso una specifica risorsa di memoria.
Messaggio originale
cannot borrow `x` as mutable more than once at a timeContesto e parole chiave
Alias
- cannot borrow as mutable more than once
- E0499
Messaggi alternativi
- doppio prestito mutabile contemporaneo
Prodotti
- Rust Compiler (rustc) / Cargo / Tokio
Piattaforme
- Linux
- macOS
- Windows
Parole chiave
- Borrow Checker e Lifetimes
- errore-rust-e0499-cannot-borrow-mutable-more-than-once
- rust
- rust.borrowck.e0499-cannot-borrow-mutable-more-than-once
Cause possibili
Causa tecnica per Errore Rust E0499: cannot borrow as mutable more than once at a time
L'errore E0499 impedisce race condition a tempo di compilazione: in Rust è consentito un solo riferimento mutabile (&mut) attivo per volta verso una specifica risorsa di memoria.
molto comuneDiagnosi
Verifica di compilazione e diagnostica per Errore Rust E0499: cannot borrow as mutable more than once at a time
Eseguire il comando cargo check per visualizzare l'output dettagliato del compilatore con suggerimenti (explain).
Come leggere il risultato. Fornisce la spiegazione estesa dell'errore di compilazione o stack trace del panic.
cargo check --explain E0499Risoluzione
Risoluzione standard per Errore Rust E0499: cannot borrow as mutable more than once at a time
Applica le correzioni consigliate per conformarsi alle regole di ownership, tipi o runtime in Rust.
- Ispezionare la riga evidenziata dal compilatore rustc
- Riformulare il codice secondo le linee guida della gestione ownership e borrow
- Eseguire cargo check per confermare la risoluzione
cargo checkDomande frequenti
Cosa significa Errore Rust E0499: cannot borrow as mutable more than once at a time?
L'errore E0499 impedisce race condition a tempo di compilazione: in Rust è consentito un solo riferimento mutabile (&mut) attivo per volta verso una specifica risorsa di memoria.
Approfondimenti
- Rust Compiler Error Index / Rust Book documentazione_ufficiale