Skip to content

Do not parse filename into String in CLI example #917

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
nagisa opened this issue Aug 19, 2019 · 2 comments
Closed

Do not parse filename into String in CLI example #917

nagisa opened this issue Aug 19, 2019 · 2 comments
Labels
A-Content The written content on the website. C-Enhancement A new feature or request

Comments

@nagisa
Copy link
Member

nagisa commented Aug 19, 2019

Content Bug Report

Page(s) Affected

https://www.rust-lang.org/what/cli

What needs to be fixed?

The example that currently reads like this:

/// Read some lines of a file
#[derive(Debug, StructOpt)]
struct Cli {
    /// Input file to read
    file: String,
    /// Number of lines to read
    #[structopt(short = "n")]
    num: usize,
}

Suggested Improvement

file should be PathBuf or OsString.

@tshepang
Copy link
Member

I'd go as far as calling the binding path, for I like reserving the name file for the handle itself (let file = File::open...)

@XAMPPRocky XAMPPRocky added A-Content The written content on the website. C-Enhancement A new feature or request labels Mar 1, 2020
@XAMPPRocky
Copy link
Member

I'm going to close this as duplicate of #838

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Content The written content on the website. C-Enhancement A new feature or request
Projects
None yet
Development

No branches or pull requests

3 participants