How to use StructOpt::from_iter()?

use structopt::StructOpt;

fn main() {
    println!("Hello, world!");
    // let k  = Cli::from_args();
    let arg = [""]; // what should be arg here
    let k = Cli::from_iter(&arg);
    println!("{:?}", k);
}

#[derive(Debug, StructOpt)]
struct Cli {
    #[structopt(short, long)]
    a: i32,
    #[structopt(short, long)]
    b: i32,
}

I have a requirement in which instead of using actual command line arguments I need to use a string from which I need to get the respective struct value.For this I can use from_iter() but I'm not able to figure out what should be the argument for it. also I can't find an example code for from_iter() in documentation as well. please help

I would assume it should be the list of command-line arguments. After all, it's an argument parsing library.

It's the list of arguments that would be given to a program. Excluding the executable name, the first argument.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.