Skip to content

Macro for constructing duct::Expression #5

@tobz1000

Description

@tobz1000

This is something I've found myself wanting as I consider migrating a project from using std::process::Command to using duct::Expression. Unfortunately there's no easy way to convert between the two types, so the command! macro can't be used.

I've made an initial implementation & tests using proc_macro; all the functionality of the command! macro is intact, with the following changes:

  • {x} takes a duct::Expression
  • (x) takes Into<OsString>, as required by Expression, rather than AsRef<OsString>; as a result, the argument is moved instead of referenced
  • [x] takes IntoIterator<Item=impl Info<OsStr>> rather than IntoIterator<Item=impl AsRef<OsStr>>

A slight rough edge is the error message if the user doesn't have the duct crate in dependencies (or it's been renamed) - this gives the error message "could not find duct in {{root}}". I'm not sure if it's possible to replace that message.

I'd be happy to update documentation and put up a PR if this would be wanted.

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