@@ -13,37 +13,33 @@ Examples
1313
1414``` rust
1515temp_env :: with_var (" MY_ENV_VAR" , Some (" production" ), || {
16- // Run some code where `MY_ENV_VAR` set to `" production" `.
16+ // Run some code where `MY_ENV_VAR` is set to `production`.
1717});
1818
1919
2020temp_env :: with_vars (
2121 [
22- (" FIRST_VAR " , Some (" Hello" )),
23- (" SECOND_VAR " , Some (" World!" )),
22+ (" FIRST " , Some (" Hello" )),
23+ (" SECOND " , Some (" World!" )),
2424 ],
2525 || {
26- // Run some code where `FIRST_VAR` is set to `"Hello"` and `SECOND_VAR` is set to
27- // `"World!"`.
26+ // Run some code where `FIRST` is set to `Hello` and `SECOND` is set to `World!`.
2827 }
2928);
3029
3130temp_env :: with_vars (
3231 [
33- (" FIRST_VAR " , Some (" Hello" )),
34- (" SECOND_VAR " , None ),
32+ (" FIRST " , Some (" Hello" )),
33+ (" SECOND " , None ),
3534 ],
3635 || {
37- // Run some code where `FIRST_VAR ` is set to `" Hello" ` and `SECOND_VAR ` is unset (even if
36+ // Run some code where `FIRST ` is set to `Hello` and `SECOND ` is unset (even if
3837 // it was set before)
3938 }
4039);
41- ```
42-
43- Starting from version 0.3.0 you can return a value from inside the closure:
4440
45- ``` rust
46- let r = temp_env :: with_var ( " MY_ENV_VAR" , Some ( " production " ), || {
41+ let value = temp_env :: with_var ( " MY_ENV_VAR " , Some ( " production " ), || {
42+ // Compute a value in a closure while ` MY_ENV_VAR` is set to `production`.
4743 let envvar = env :: var (" MY_ENV_VAR" ). unwrap ();
4844 if envvar == " production" {
4945 true
0 commit comments