2 ms·
What even is "if let ..." in Rust? What is the purpose of it? need_explicit_dep_target = true; if let DepArgumentRequirePath::NotNeeded = need_explicit
by johnisgood 4y ago
What even is "if let ..." in Rust? What is the purpose of it?
need_explicit_dep_target = true;
if let DepArgumentRequirePath::NotNeeded = need_explicit_dep_argument_path {
need_explicit_dep_argument_path = DepArgumentRequirePath::Missing;
}
I am currently trying to translate "simple" Rust code to C but I am having difficulties.
https://github.com/RustCrypto/formats/blob/master/base32ct/src/alphabet.rs#L43 https://github.com/RustCrypto/formats/blob/master/base32ct/s...
Where is `threshold` and `offset` coming from?
How come running `cargo test` in directory `base32ct` actually tests nothing (I get 0 everywhere) despite there being some test code? Messed up `Cargo.toml` file? sighs
Lots of mysteries in Rust, at least for me.
- nu11ptr 4y agoThe purpose is to enter the if block if and only if the pattern is matched. In your example, if "need_explicit_dep_argument_path" matches enum "DepArgumentRequirePath::NotNeeded" the if block will be entered (else it will be skipped). This is a bit of an atypical example as there are no bindings in the pattern match, but most times there are, and they are then scoped within the if block. For example: let my_option = Some("test"); if let Some(my_str) = my_option { println!("I matched this string: {my_str}"); }