Pastebin
Retrouvez, créez et partagez vos snippets en temps réel.
Rechercher un Pastebin
Aucun paste trouvé.
Créer un paste
Pastebin
Blog
Aaaaaaaaaaa
┌─[mothersphere@archlinux] - [Grape] - [ main +266 / -5 ] └─>[$] cargo run Compiling grape v0.1.0 (/home/mothersphere/Grape) error[E0502]: cannot borrow `state` as mutable because it is also borrowed as immutable --> src/main.rs:313:13 | 312 | if let Some(entry) = state.filtered_library.get(index as usize) { | ----- immutable borrow occurs here 313 | state.current_track = entry.track.clone(); | ^^^^^ mutable borrow occurs here 314 | state.current_track_path = entry.path.clone(); | ---------- immutable borrow later used here error[E0502]: cannot borrow `state` as mutable because it is also borrowed as immutable --> src/main.rs:314:13 | 312 | if let Some(entry) = state.filtered_library.get(index as usize) { | ----- immutable borrow occurs here 313 | state.current_track = entry.track.clone(); 314 | state.current_track_path = entry.path.clone(); | ^^^^^ mutable borrow occurs here 315 | state.current_duration = entry.duration; | -------------- immutable borrow later used here error[E0502]: cannot borrow `state` as mutable because it is also borrowed as immutable --> src/main.rs:315:13 | 312 | if let Some(entry) = state.filtered_library.get(index as usize) { | ----- immutable borrow occurs here ... 315 | state.current_duration = entry.duration; | ^^^^^ mutable borrow occurs here 316 | if let Some(path) = entry.path.clone() { | ---------- immutable borrow later used here error[E0502]: cannot borrow `state` as mutable because it is also borrowed as immutable --> src/main.rs:317:35 | 312 | if let Some(entry) = state.filtered_library.get(index as usize) { | ----- immutable borrow occurs here ... 317 | if let Err(err) = state.player.load(path) { | ^^^^^ mutable borrow occurs here ... 322 | sync_current_track(&main_window, &entry.track); | ------------ immutable borrow later used here warning: variable does not need to be mutable --> src/main.rs:357:9 | 357 | let mut timer = slint::Timer::default(); | ----^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default For more information about this error, try `rustc --explain E0502`. warning: `grape` (bin "grape") generated 1 warning error: could not compile `grape` (bin "grape") due to 4 previous errors; 1 warning emitted ┌─[mothersphere@archlinux] - [Grape] - [ main +266 / -5 ] [5s126ms] └─>[$] rustc --explain E0502 A variable already borrowed with a certain mutability (either mutable or immutable) was borrowed again with a different mutability. Erroneous code example: fn bar(x: &mut i32) {} fn foo(a: &mut i32) { let y = &a; // a is borrowed as immutable. bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed // as immutable println!("{}", y); } To fix this error, ensure that you don't have any other references to the variable before trying to access it with a different mutability: fn bar(x: &mut i32) {} fn foo(a: &mut i32) { bar(a); let y = &a; // ok! println!("{}", y); } For more information on Rust's ownership system, take a look at the References & Borrowing section of the Book. ┌─[mothersphere@archlinux] - [Grape] - [ main +266 / -5 ] └─>[$]
Créé il y a 3 semaines.