Executando verificação de segurança...
2

[AJUDA] Rodando a lib CLAP no rust

Olá Pessoal. Estou tentando rodar um código que vi na documentação do rust que usa a lib do clap para passar argumentos no terminal:

use clap::Parser;

/// Simple program to greet a person
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
    /// Name of the person to greet
    #[arg(short, long)]
    name: String,

    /// Number of times to greet
    #[arg(short, long, default_value_t = 1)]
    count: u8,
}

fn main() {
    let args = Args::parse();

    for _ in 0..args.count {
        println!("Hello {}!", args.name)
    }
}

eu rodei o comando para adicionar as dependências:

cargo add clap --features derive

Mas obtive o erro:

error: cannot find attribute `command` in this scope
 --> src/main.rs:5:3
  |
5 | #[command(version, about, long_about = None)]
  |   ^^^^^^^

error: cannot find attribute `arg` in this scope
 --> src/main.rs:8:7
  |
8 |     #[arg(short, long)]
  |       ^^^

error: cannot find attribute `arg` in this scope
  --> src/main.rs:12:7
   |
12 |     #[arg(short, long, default_value_t = 1)]
   |       ^^^

Quem souber e puder me dar um help, obrigado!

Carregando publicação patrocinada...
2
1

Olá. O erro ainda aparece:

error: cannot find attribute `command` in this scope
 --> src/main.rs:5:3
  |
5 | #[command(version, about, long_about = None)]
  |   ^^^^^^^
  |
note: `command` is imported here, but it is a function-like macro
 --> src/main.rs:1:25
  |
1 | use clap::{Parser, arg, command};
  |                         ^^^^^^^

error: cannot find attribute `arg` in this scope
 --> src/main.rs:8:7
  |
8 |     #[arg(short, long)]
  |       ^^^
  |
note: `arg` is imported here, but it is a function-like macro
 --> src/main.rs:1:20
  |
1 | use clap::{Parser, arg, command};
  |                    ^^^

error: cannot find attribute `arg` in this scope
  --> src/main.rs:12:7
   |
12 |     #[arg(short, long, default_value_t = 1)]
   |       ^^^
   |
note: `arg` is imported here, but it is a function-like macro
  --> src/main.rs:1:20
   |
1  | use clap::{Parser, arg, command};
   |                    ^^^

error: could not compile `proj_11_05` (bin "proj_11_05") due to 3 previous errors

A versão é acima da 3.