No function or associated item named in the current scope

Hi there,

I had a naive question ( I am fairly new to this amazing language ) and was hoping to get some help.

I have a struct called Args in a file called **** under src directory.

use std::path::PathBuf;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
    name = "build_script",
    about = "A script that builds and installs a project",
    rename_all = "kebab-case"
pub struct Args {
    workspace_location: PathBuf,

Now in the src/, I would like to use this structure but keep getting this error:

**no function or associated item named from_argsfound for structcontext_args::Args in the current scope**

mod context_args;
use context_args::Args;

fn main() {
    let args = Args::from_args(); // error function or associated item not found in `context_args::Args`

What am I doing wrong and how can I fix this?

from_args is a trait method, and trait methods can only be called when they're in scope. Add use structopt::StructOpt; in to bring the trait into scope.

Thank you @semicoleon . That did it.

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.