Skip to content

Conversation

@siphonelee
Copy link

No description provided.

Calvin added 3 commits August 22, 2025 22:09
  --> src/main.rs:44:16
   |
44 |         sum += adder.compute(10); // 隐式转换 i32 到 i64
   |                ^^^^^^^^^^^^^^^^^ expected , found

error[E0277]: cannot add-assign  to
let mut sum: i64 = 0;
for _ in 0..1000000 {
sum += adder.compute(10); // 隐式转换 i32 到 i64
sum += adder.compute(10) as i64; // 隐式转换 i32 到 i64
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加了 as i64,就不是隐式转换了

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加了 as i64,就不是隐式转换了

是的是的,忘了改之前的注释,rust不支持这种隐式转换。重新改了一下注释

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants