Giter VIP home page Giter VIP logo

Comments (6)

dtolnay avatar dtolnay commented on July 18, 2024

This is intentional, you call env n times to get a vector of n environment variables. We don't need to require that the caller provide >0 environment variables.

from proc-macro-workshop.

jecolon avatar jecolon commented on July 18, 2024

But is the test not passing also intentional? To make it pass and satisfy your requirement, env should be optional then, right?

from proc-macro-workshop.

dtolnay avatar dtolnay commented on July 18, 2024

It doesn't need to be wrapped in Option because an empty vec already tells the user of Command that env was called 0 times. The user of Command doesn't need the field to be wrapped in Option to tell them that; I think the test case should pass as written, with the appropriate implementation of the macro.

from proc-macro-workshop.

jecolon avatar jecolon commented on July 18, 2024

OK I see. Thanks for the insight!

from proc-macro-workshop.

ririsoft avatar ririsoft commented on July 18, 2024

@dtolnay I fall into the same issue. I totally follow you on this one, but I could not find a specification for it in the comments. Maybe this could be added to 06-optional-field with a comment and test case ?

from proc-macro-workshop.

kziemianek avatar kziemianek commented on July 18, 2024

In test 4 there is the requirement:

// Generate a build method to go from builder to original struct.
//
// This method should require that every one of the fields has been explicitly
// set; it should return an error if a field is missing. The precise error type
// is not important. Consider using Box, which you can construct
// using the impl From for Box

env is a field and it's not set in test 7 so my implementation also fails. I see room for a small improvement. It could be explicitly specified that for vec we don't need to check this condition.

@dtolnay thanks for great learning resource.

from proc-macro-workshop.

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.