Skip to content

Initial example Clap implementation has deprecation warnings - Command Line Applications In Rust #147

Description

@ConnorJamesLow

I am following the Command Line Applications In Rust tutorial using Rust 2021 edition. The book contains the following code:

#![allow(unused)]

use clap::Parser;

/// Search for a pattern in a file and display the lines that contain it.
#[derive(Parser)]
struct Cli {
    /// The pattern to look for
    pattern: String,
    /// The path to the file to read
    #[clap(parse(from_os_str))]
    path: std::path::PathBuf,
}

fn main() {
    let args = Cli::parse();
}

Which produces the following warnings:

image

Possible solutions:

  • Update the book to use non-deprecated code.
  • Else, if this was at one time stable, provide more specific versioning for Clap and Rust (adding the dependency according to the guide gave me clap v3.2.1).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions