Closed rubo77 closed 4 years ago
I fixed all errors but one, that I don't understand:
error[E0382]: borrow of moved value: `cur_nodes_map`
--> src/cron.rs:157:41
|
143 | for (_id, cur_data) in cur_nodes_map.into_iter() {
| ------------- value moved here
...
157 | if let Some(cur_data) = cur_nodes_map.remove(&id) {
| ^^^^^^^^^^^^^ value borrowed here after move
|
= note: move occurs because `cur_nodes_map` has type `std::collections::HashMap<std::string::String, cron::NodeData>`, which does not implement the `Copy` trait
into_iter
consumes cur_nodes_map
. Try using iter
instead.
into_iter
consumescur_nodes_map
. Try usingiter
instead.
BUt the code later uses into_iter
also in the same manner. Why would there be the difference needed?
BUt the code later uses into_iter also in the same manner. Why would there be the difference needed?
Because the code later is the last time the map is used.
After using into_iter
, you cannot use the map ever again later. So it's okay for the last iteration, but not before.
See https://doc.rust-lang.org/book/ch04-00-understanding-ownership.html
I don't understand this error: https://travis-ci.org/github/freifunk-saar/ff-node-monitor/builds/698531035#L502
()
has type ()
but you need to return something of type Result<()>
.
Try return Ok(());
.
Try
return Ok(());
.
now it compiles well.
I guess, I could also have used just
OK(())
(without semicolon)
If the expression is the last in the block, yes. But not here which is in the middle of the body. Early return
still needs return
in Rust.
bors r+
bors retry
Already running a review
Build succeeded:
I get some errors when compiling .
i did never program Rust so far, but I guess you find my errors immediately ;)
closes #66