Post
Share your knowledge.
skywinder271
Jan 23, 2025
Expert Q&A
How to resolve mutable borrow error in Rust function?
I'm encountering an error while trying to get a value from an object in two places within the same Rust function. The error states it's still being mutably borrowed. How do I resolve this?
- Move CLI
3
2
Share
Comments
Answers
2Xavier.eth260
Jan 23 2025, 15:56To resolve this, ensure that the first mutable reference (b1_obj
) goes out of scope before attempting to borrow the object again with the second mutable reference (b2_obj
).
3
Best Answer
Comments
Grizzly67
Jan 23 2025, 09:10This error occurs because you cannot have more than one mutable reference to the same object at the same time in Rust.
1
Comments
Do you know the answer?
Please log in and share it.
Move is an executable bytecode language used to implement custom transactions and smart contracts.
148Posts231Answers

Reward CampaignJune
- ... SUIderiss+5
- ... SUIRamirez+5
- ... SUIElvin CLONE +5
- ... SUI
- ... SUI
- ... SUI
- ... SUIBritain+2
Bounty Posts