Miscellaneous
Tips and Tricks
Random tips and tricks
- Run
cargo clippy
command - Crates.io for rust is same as NPM for JavaScript
- Some examples are from https://rust-lang-nursery.github.io/rust-cookbook/intro.html
Errors and Solutions
[Stuck] Blocking waiting for file lock on package cache Delete .package-cache
file
rm ~/.cargo/.package-cache
Order and Priority
See how adding parantheses, changed the result. It is not about the order here, always &&
will happen before ||
Program
fn main() { let (a, b, c) = (true, true, false); let mut d;
println!("a is {}, b is {}, c is {}", a, b, c);
d = a || b && c; println!("a || b && c, \t => {}", d);
d = (a || b) && c; println!("(a || b) && c, \t => {}", d);
d = c && a || b; println!("c && a || b, \t => {}", d);}
Result
a is true, b is true, c is falsea || b && c, => true(a || b) && c, => falsec && a || b, => true