Open matzipan opened 10 months ago
Ok if I see this correctly there are multiple things going on. Since it seems you want to remove the unused_mut
warning for your iterator let's look at this.
In your first code block the mut
is indeed not needed.
let mut iterator = UidFetchIterator::new(uid_range_start, uid_range_end);
for (fetch_range_start, fetch_range_end) in iterator {
let mut messages = connection
If I get it correctly the for-loop will use the IntoIterator Trait to convert your iterator and therefore your iterator
variable does not need to be mutable. See also here for the desugaring of the for-loop.
In your second example you call the next()
method directly on you iterator.
error[E0596]: cannot borrow `iterator` as mutable, as it is not declared as mutable
--> app/src/backends/imap/sync.rs:141:60
|
141 | while let Some((fetch_range_start, fetch_range_end)) = iterator.next() {
| ^^^^^^^^ cannot borrow as mutable
|
help: consider changing this to be mutable
|
139 | let mut iterator = UidFetchIterator::new(uid_range_start, uid_range_end);
| +++
This produces an error since the next()
method takes a mutable reference to self
and therefore your iterator
variable needs to be marked as mutable.
If i see it correctly the remaining errors are decoupled from the mut
problematic and the issue there is that you are trying to use something that got moved out of scope.
I hope this helps a little bit, if you have any questions feel free to ask.
Hi,
Thanks for the prompt response. It is indeed so. I think your suggestion matches the code that I eventually pushed: https://github.com/matzipan/envoyer/commit/ca27349ad56215837085a80ef376da3ad9038c1b
But I don't want this ticket to be misunderstood. It's not a support ticket from my side. I just opened it because the error message told me so.
If there's nothing to be fixed here in clopot, feel free to close.
Summary
Clippy produced the following message:
Removing the two
mut
qualifiers produces:and
Reproducer
The code in question:
Version
Additional Labels
@rustbot label +I-suggestion-causes-error