You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the fake git mocks, we want simple binaries with the least number of dependencies. So, for CLI options that are dead simple, we don't want to use CLAP (like we do in the actual product binaries). We ran into an issue with matching on Option that required some ugly looking code:
let first_arg = env::args().nth(1);
match first_arg {
None => exit(1),
Some(val) => {
if val == "--version" {
println!("fake_git version 1");
} else {
exit(1);
}
}
};
For some reason, we could not match using something like Some("--version"). Should be doable and much cleaner to do it this... but how?
The text was updated successfully, but these errors were encountered:
I don't even remotely understand that, because I had been under the impression that str was a reference type for String. But moving past that... it looks like that, since any type implementing the Deref specifies what its associated Target type is, then Option's as_deref method has enough information to convert the value type into its associated target. Or something. I'm lost.
I'm glad you found this, I never would have been able to work it out from first principals.
With the fake git mocks, we want simple binaries with the least number of dependencies. So, for CLI options that are dead simple, we don't want to use CLAP (like we do in the actual product binaries). We ran into an issue with matching on Option that required some ugly looking code:
For some reason, we could not match using something like
Some("--version")
. Should be doable and much cleaner to do it this... but how?The text was updated successfully, but these errors were encountered: