@@ -105,11 +105,13 @@ fn test_parse_int() {
105105 env:: set_var ( "INT_VAL" , "42" ) ;
106106
107107 let environment = Environment :: new ( ) . try_parsing ( true ) ;
108- let mut config = Config :: default ( ) ;
109108
110- config. set ( "tag" , "Int" ) . unwrap ( ) ;
111-
112- config. merge ( environment) . unwrap ( ) ;
109+ let config = Config :: builder ( )
110+ . set_default ( "tag" , "Int" )
111+ . unwrap ( )
112+ . add_source ( environment)
113+ . build ( )
114+ . unwrap ( ) ;
113115
114116 let config: TestIntEnum = config. try_into ( ) . unwrap ( ) ;
115117
@@ -135,11 +137,13 @@ fn test_parse_float() {
135137 env:: set_var ( "FLOAT_VAL" , "42.3" ) ;
136138
137139 let environment = Environment :: new ( ) . try_parsing ( true ) ;
138- let mut config = Config :: default ( ) ;
139-
140- config. set ( "tag" , "Float" ) . unwrap ( ) ;
141140
142- config. merge ( environment) . unwrap ( ) ;
141+ let config = Config :: builder ( )
142+ . set_default ( "tag" , "Float" )
143+ . unwrap ( )
144+ . add_source ( environment)
145+ . build ( )
146+ . unwrap ( ) ;
143147
144148 let config: TestFloatEnum = config. try_into ( ) . unwrap ( ) ;
145149
@@ -168,11 +172,13 @@ fn test_parse_bool() {
168172 env:: set_var ( "BOOL_VAL" , "true" ) ;
169173
170174 let environment = Environment :: new ( ) . try_parsing ( true ) ;
171- let mut config = Config :: default ( ) ;
172-
173- config. set ( "tag" , "Bool" ) . unwrap ( ) ;
174175
175- config. merge ( environment) . unwrap ( ) ;
176+ let config = Config :: builder ( )
177+ . set_default ( "tag" , "Bool" )
178+ . unwrap ( )
179+ . add_source ( environment)
180+ . build ( )
181+ . unwrap ( ) ;
176182
177183 let config: TestBoolEnum = config. try_into ( ) . unwrap ( ) ;
178184
@@ -202,11 +208,13 @@ fn test_parse_off_int() {
202208 env:: set_var ( "INT_VAL_1" , "42" ) ;
203209
204210 let environment = Environment :: new ( ) . try_parsing ( false ) ;
205- let mut config = Config :: default ( ) ;
206211
207- config. set ( "tag" , "Int" ) . unwrap ( ) ;
208-
209- config. merge ( environment) . unwrap ( ) ;
212+ let config = Config :: builder ( )
213+ . set_default ( "tag" , "Int" )
214+ . unwrap ( )
215+ . add_source ( environment)
216+ . build ( )
217+ . unwrap ( ) ;
210218
211219 env:: remove_var ( "INT_VAL_1" ) ;
212220
@@ -231,11 +239,13 @@ fn test_parse_off_float() {
231239 env:: set_var ( "FLOAT_VAL_1" , "42.3" ) ;
232240
233241 let environment = Environment :: new ( ) . try_parsing ( false ) ;
234- let mut config = Config :: default ( ) ;
235-
236- config. set ( "tag" , "Float" ) . unwrap ( ) ;
237242
238- config. merge ( environment) . unwrap ( ) ;
243+ let config = Config :: builder ( )
244+ . set_default ( "tag" , "Float" )
245+ . unwrap ( )
246+ . add_source ( environment)
247+ . build ( )
248+ . unwrap ( ) ;
239249
240250 env:: remove_var ( "FLOAT_VAL_1" ) ;
241251
@@ -260,11 +270,13 @@ fn test_parse_off_bool() {
260270 env:: set_var ( "BOOL_VAL_1" , "true" ) ;
261271
262272 let environment = Environment :: new ( ) . try_parsing ( false ) ;
263- let mut config = Config :: default ( ) ;
264-
265- config. set ( "tag" , "Bool" ) . unwrap ( ) ;
266273
267- config. merge ( environment) . unwrap ( ) ;
274+ let config = Config :: builder ( )
275+ . set_default ( "tag" , "Bool" )
276+ . unwrap ( )
277+ . add_source ( environment)
278+ . build ( )
279+ . unwrap ( ) ;
268280
269281 env:: remove_var ( "BOOL_VAL_1" ) ;
270282
@@ -289,11 +301,13 @@ fn test_parse_int_fail() {
289301 env:: set_var ( "INT_VAL_2" , "not an int" ) ;
290302
291303 let environment = Environment :: new ( ) . try_parsing ( true ) ;
292- let mut config = Config :: default ( ) ;
293304
294- config. set ( "tag" , "Int" ) . unwrap ( ) ;
295-
296- config. merge ( environment) . unwrap ( ) ;
305+ let config = Config :: builder ( )
306+ . set_default ( "tag" , "Int" )
307+ . unwrap ( )
308+ . add_source ( environment)
309+ . build ( )
310+ . unwrap ( ) ;
297311
298312 env:: remove_var ( "INT_VAL_2" ) ;
299313
@@ -318,11 +332,13 @@ fn test_parse_float_fail() {
318332 env:: set_var ( "FLOAT_VAL_2" , "not a float" ) ;
319333
320334 let environment = Environment :: new ( ) . try_parsing ( true ) ;
321- let mut config = Config :: default ( ) ;
322-
323- config. set ( "tag" , "Float" ) . unwrap ( ) ;
324335
325- config. merge ( environment) . unwrap ( ) ;
336+ let config = Config :: builder ( )
337+ . set_default ( "tag" , "Float" )
338+ . unwrap ( )
339+ . add_source ( environment)
340+ . build ( )
341+ . unwrap ( ) ;
326342
327343 env:: remove_var ( "FLOAT_VAL_2" ) ;
328344
@@ -347,11 +363,13 @@ fn test_parse_bool_fail() {
347363 env:: set_var ( "BOOL_VAL_2" , "not a bool" ) ;
348364
349365 let environment = Environment :: new ( ) . try_parsing ( true ) ;
350- let mut config = Config :: default ( ) ;
351-
352- config. set ( "tag" , "Bool" ) . unwrap ( ) ;
353366
354- config. merge ( environment) . unwrap ( ) ;
367+ let config = Config :: builder ( )
368+ . set_default ( "tag" , "Bool" )
369+ . unwrap ( )
370+ . add_source ( environment)
371+ . build ( )
372+ . unwrap ( ) ;
355373
356374 env:: remove_var ( "BOOL_VAL_2" ) ;
357375
@@ -375,11 +393,13 @@ fn test_parse_string() {
375393 env:: set_var ( "STRING_VAL" , "test string" ) ;
376394
377395 let environment = Environment :: new ( ) . try_parsing ( true ) ;
378- let mut config = Config :: default ( ) ;
379396
380- config. set ( "tag" , "String" ) . unwrap ( ) ;
381-
382- config. merge ( environment) . unwrap ( ) ;
397+ let config = Config :: builder ( )
398+ . set_default ( "tag" , "String" )
399+ . unwrap ( )
400+ . add_source ( environment)
401+ . build ( )
402+ . unwrap ( ) ;
383403
384404 let config: TestStringEnum = config. try_into ( ) . unwrap ( ) ;
385405
@@ -409,11 +429,13 @@ fn test_parse_off_string() {
409429 env:: set_var ( "STRING_VAL_1" , "test string" ) ;
410430
411431 let environment = Environment :: new ( ) . try_parsing ( false ) ;
412- let mut config = Config :: default ( ) ;
413-
414- config. set ( "tag" , "String" ) . unwrap ( ) ;
415432
416- config. merge ( environment) . unwrap ( ) ;
433+ let config = Config :: builder ( )
434+ . set_default ( "tag" , "String" )
435+ . unwrap ( )
436+ . add_source ( environment)
437+ . build ( )
438+ . unwrap ( ) ;
417439
418440 let config: TestStringEnum = config. try_into ( ) . unwrap ( ) ;
419441
0 commit comments