Move.

帖子

分享您的知识。

skywinder.
Jan 23, 2025
专家问答

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
分享
评论
.

答案

2
Xavier.eth.
Jan 23 2025, 15:56

b1_obj要解决此问题,请确保第一个可变引用 (b2_obj) 超出范围,然后尝试使用第二个可变引用 () 再次借用该对象.

3
最佳答案
评论
.
Grizzly.
Jan 23 2025, 09:10

之所以发生此错误,是因为在 Rust 中你不能同时对同一个对象进行多个可变引用.

1
评论
.

你知道答案吗?

请登录并分享。

Move is an executable bytecode language used to implement custom transactions and smart contracts.

148帖子231答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。

奖励活动七月