Skip to content

Multiple errors in getopt example #1833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mcandre opened this issue Feb 13, 2012 · 1 comment
Closed

Multiple errors in getopt example #1833

mcandre opened this issue Feb 13, 2012 · 1 comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Milestone

Comments

@mcandre
Copy link

mcandre commented Feb 13, 2012

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 is vec::tail.

@brson
Copy link
Contributor

brson commented May 1, 2012

Fixed by bkircher

@brson brson closed this as completed May 1, 2012
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
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
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants