I am looking at some older code from David Simmons (TUPM) where I don't understand why the compiler wants to move an object while I am just executing a method in the object. Yes, I am new at Rust, so I might be overlooking something obvious. The code lines are:
65 fn new(url: &str, http_username: &str, http_password: &str) -> Repository {
66 // Create a new reqwest client.
67 let client_builder = reqwest::ClientBuilder::new();
68 client_builder.timeout(Duration::from_secs(TIMEOUT_SECS));
69 let client = match client_builder.build() {
The messages from the compiler are:
gbonnema ~ projects rust tupm cargo build
Compiling tupm v0.1.0 (/home/data/gbonnema/projects/rust/tupm)
error[E0382]: use of moved value: `client_builder`
--> src/upm/sync.rs:69:28
|
68 | client_builder.timeout(Duration::from_secs(TIMEOUT_SECS));
| -------------- value moved here
69 | let client = match client_builder.build() {
| ^^^^^^^^^^^^^^ value used here after move
|
= note: move occurs because `client_builder` has type `reqwest::ClientBuilder`, which does not implement the `Copy` trait
What I don't understand is why the compiler considers the execution of a method on the object equivalent to a move of the object.
Can anyone point me in the right direction?
P.S. I am reading the (paper version) of the community book (2nd edition) and have just started reading the o'reilly book (Programming rust).