为什么调用count就会移动了?
use std::env;fn main() -> std::io::Result<()> {let mut param = env::args();let paramCount = param.count();println!("count ={}", paramCount);let a = param.next();println!("a = {:?}", a);
}
6 | let mut param = env::args();| --------- move occurs because `param` has type `Args`, which does not implement the `Copy` trait
7 |
8 | let paramCount = param.count();| ------- `param` moved due to this method call
...
11 | let a = param.next();| ^^^^^ value borrowed here after move|
note: this function takes ownership of the receiver `self`, which moves `param`--> /root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:203:14|
203 | fn count(self) -> usize| ^^^^For more information about this error, try `rustc --explain E0382`.