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
For instance, the example code attempts to shift the CLI arguments in order to drop the program name and pass the rest into the getopt parser. But the way the example code uses vec::shift is incorrect. This function indeed drops the first element, but it returns the element, not the rest of the vector.
The example code neglects to inform coders how to properly import the various getopt functions (there are several), and how to import the maybe type (opt_maybe_str).
Finally, the example code fails to operate due to the nature of vec::shift; even when used properly according to the docs, this function is designed for mutable vectors, not the constant vector of CLI arguments. A better choice is vec::tail.
The text was updated successfully, but these errors were encountered:
For now I just moved the reachability code to this new module. As a follow up PR, I am planning to move the unsized coercion related code into a separate module so it can be used to refactor and fix codegen casting logic (related issues rust-lang#1531, rust-lang#566, and rust-lang#1528) .
Kobzol
pushed a commit
to Kobzol/rust
that referenced
this issue
Dec 30, 2024
The getopt example in the docs has several errors which prevent it, and any code based on it, from running.
getopttest.rs based on the docs
getopttest2.rs resolved multiple errors
For instance, the example code attempts to shift the CLI arguments in order to drop the program name and pass the rest into the getopt parser. But the way the example code uses
vec::shift
is incorrect. This function indeed drops the first element, but it returns the element, not the rest of the vector.The example code neglects to inform coders how to properly import the various getopt functions (there are several), and how to import the maybe type (
opt_maybe_str
).Finally, the example code fails to operate due to the nature of
vec::shift
; even when used properly according to the docs, this function is designed for mutable vectors, not the constant vector of CLI arguments. A better choice isvec::tail
.The text was updated successfully, but these errors were encountered: