Git Product home page Git Product logo

Comments (5)

Kobzol avatar Kobzol commented on July 22, 2024 1

FWIW, I tried to remove the macro by implementing Deref/DerefMut<Target=Command> for the wrappers instead. It would have worked.. were it not for the builder pattern :) Because if we implement the helper functions (like env) on Command directly, then they have to return &mut Self, which means that you would have to use all of the top-level command wrapper methods before using any of the Command methods, which is annoying. For example, rustc().crate_type().env() would work, but rustc().env().crate_type() wouldn't work, because env() would return Command, and not Rustc.

I'm not aware of any way of resolving this without using a macro. That being said, I think that the current macro is fine, it just adds a bunch of methods, and does not have any specific requirements on the wrapper apart from having a cmd field. The documentation needs to be updated though (#126188).

from rust.

jieyouxu avatar jieyouxu commented on July 22, 2024 1

I'm going to close this issue, because I think using a trait here unfortunately just makes the API worse.

from rust.

jieyouxu avatar jieyouxu commented on July 22, 2024

Drawback: test writer would need to bring the trait into scope to use the helper methods...

from rust.

ChrisDenton avatar ChrisDenton commented on July 22, 2024

There could be inherent methods that simply forward to the trait methods. That's more boilerplate though.

from rust.

Kobzol avatar Kobzol commented on July 22, 2024

We don't need command_output on each wrapper struct anymore as of #126121. I don't think that a trait pulls its weight here, due the tests having to import it (it's a bit annoying since run-make tests are typically not very friendly with IDEs). It would be nice to remove the macro, but we can do that also with other approaches than a trait (e.g. Deref).

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.