Skip to content

Rust suggests me to make a mutable variable mutable? #46834

Closed
@jD91mZM2

Description

@jD91mZM2
error[E0594]: cannot assign to captured outer variable in an `Fn` closure
   --> main.rs:232:9
    |
225 |     let mut typing_last = Instant::now();
    |         --------------- help: consider making `mut typing_last` mutable: `mut mut typing_last`
...
232 |         typing_last = Instant::now();
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
help: consider changing this closure to take self by mutable reference
   --> main.rs:228:40
    |
228 |       input.connect_property_text_notify(move |input| {
    |  ________________________________________^
229 | |         if typing_last.elapsed() < typing_duration {
230 | |             return;
231 | |         }
...   |
234 | |         println!("{:?}", text);
235 | |     });
    | |_____^

help: consider making mut typing_last mutable: mut mut typing_last

Sadly I can't seems to find a minimal reproduction example where this appears, but I commited all my code to a separate branch so you can look at the code (or try to compile it yourself): rust-weird-error.

I'm sorry, but that's all I have on this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions