Skip to content

Allowing self.field in cmd! macro #62

@rewk

Description

@rewk

Hi,

Would it be possible to allow using self.field in cmd! macros ?
For example, this would allow to use a struct to store common args of commands.

struct Commons {
    sh: Shell,
    field: String,
}

impl Commons {
    fn execute(&self) {
        let command = cmd!(self.sh, "echo {self.field}");
        command.run();
    }
}

I have not attempted to make the change, so that i don't know if it would be possible.

If the self. is removed from the above code, the compiler hints at something that would work.

error[E0425]: cannot find value `field` in this scope
  --> src/main.rs:88:13
   |
88 | /             "
89 | |             echo {field}
90 | |             "
   | |_____________^ help: you might have meant to use the available field: `self.field`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions