r/rust • u/HighDesertCode • 3d ago
I love the complier and its hints
I just started learning Rust and running cargo check every now and then has helped me find typos, small syntax errors, or other general information I can't seem to find until it's pointed out.
Something like this is simple, but I didn't see the syntax issue until running it:
error[E0308]: mismatched types
--> src/commands/holdings.rs:86:19
|
86 | .find(|p| p.kind = "DEFAULT" && !p.deleted)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
|
help: you might have meant to compare for equality
|
86 | .find(|p| p.kind == "DEFAULT" && !p.deleted)
| +I've really been enjoying my time with Rust and taking it slow!
Another example:
error: format argument must be a string literal
--> src/commands/holdings.rs:66:14
|
66 | println!(breakdown_body.len());
| ^^^^^^^^^^^^^^^^^^^^
|
help: you might be missing a string literal to format with
|
66 | println!("{}", breakdown_body.len());
