Comments (6)
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.
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.
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.
OK I see. Thanks for the insight!
from proc-macro-workshop.
@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.
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)
- Lesson 3
- Compile fail on newer version of syn and quote on derive_builder unrecognize attribute test HOT 1
- Why span in `compile_error!` error message include the ending `;` ? HOT 2
- Update projects and tests to 2021 edition HOT 1
- What to do? HOT 3
- Help with Cargo Expand? HOT 2
- links to industrial implementations HOT 1
- Unused code warning in sorted 04 HOT 2
- Full path in compiler error for bitfield 04 HOT 2
- Nothing is implemented HOT 1
- [Help] How to parsing multi recursive proc macros ? HOT 1
- Seq05 would break multiple other tests. HOT 3
- The dependencies in most of the Cargo.tomls are still `# TODO` HOT 1
- What is best way to print whole path HOT 1
- Reference implementation of bitfield HOT 1
- Sorted: Tests for sorted match expressions do not catch if you always compare to the first arm
- em.i konw three marco ,but still don't konw how to do
- The build function in Builder derive macro should take ownership HOT 1
- Getting the correct span for multi-segment Path HOT 1
- seq test case 03 fail HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proc-macro-workshop.