Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

armanriazi•rust•error•already borrowed: BorrowMutError

   let mut base_3 = base.borrow_mut();
   base_3.radio_freq += 43.21; //** main issue. you need to define this line in interior block like line scope 7 so line 2 is wrong when placed in main scope
 
   println!("base: {:?}", base);
   println!("base_3: {:?}", base_3);

   {
    let mut base_4 = base.borrow_mut();//'already borrowed: BorrowMutError'
    base_4.radio_freq -= 3.52;
    println!("base_2: {:?}", base_4);
   }
   
   /*
   base: RefCell { value: <borrowed> }  //**
   base_3: GroundStation { radio_freq: 118.52000000000001 }
   thread 'main' panicked at 'already borrowed: BorrowMutError'
   */
 
PREVIOUS NEXT
Tagged: #BorrowMutError
ADD COMMENT
Topic
Name
7+2 =