dtolnay / proc-macro-workshop

Learn to write Rust procedural macros  [Rust Latam conference, Montevideo Uruguay, March 2019]
Apache License 2.0
4k stars 1.01k forks source link

Update 07-repeated-field.rs #62

Closed gftea closed 1 year ago

gftea commented 1 year ago

env is mandatory field

gftea commented 1 year ago

@dtolnay I got error in 07 testcase because env is None. Anything I missed?

dtolnay commented 1 year ago

If the user calls env n times, they need to get a vector of n environment variables. So for example they can call 2 times to get 2 elements in the vector (this is tested by assert_eq!(command.args, vec!["build", "--release"])). Or they call 0 times to get 0 elements in the vector.

gftea commented 1 year ago

If the user calls env n times, they need to get a vector of n environment variables. So for example they can call 2 times to get 2 elements in the vector (this is tested by assert_eq!(command.args, vec!["build", "--release"])). Or they call 0 times to get 0 elements in the vector.

thanks, I see your explanation I interpret mandatory field is that user at least call 1 time, because env is not a Option field, so we should report error if no env is set by user