Debian Codegraph @

tests/test.rs

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 use configparserrust-analyzer cargo configparser 3.0.3 crate/::inirust-analyzer cargo configparser 3.0.3 ini/::Inirust-analyzer cargo configparser 3.0.3 ini/Ini#;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#;
3
4 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
5 #[allow(clippy::approx_constant)]
6 fn non_csrust-analyzer cargo configparser 3.0.3 non_cs().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
•7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
8 let mut config = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::newrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new().();
9 let map = config.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
10 config.set_comment_symbolsrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]set_comment_symbols().(&[';', '#', '!']);
11 let inpstring = config.readrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]read().(
12 "defaultvalues=defaultvalues
13 [topsecret]
14 KFC = the secret herb is orega-
15 colon:value after colon
16 Empty string =
17 None string
18 Password=[in-brackets]
19 [ spacing ]
20 indented=indented
21 not indented = not indented ;testcomment
22 !modified comment
23 [values]#another comment
24 Bool = True
25 Boolcoerce = 0
26 Int = -31415
27 Uint = 31415
28 Float = 3.1415"
29 .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
30 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
31 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map, inpstring);
32 config.setrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]set().("DEFAULT", "defaultvalues", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("notdefault".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()));
33 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
34 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("DEFAULT", "defaultvalues").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
35 "notdefault"
36 );
37 config.setstrrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]setstr().("DEFAULT", "defaultvalues", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("defaultvalues"));
38 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
39 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("DEFAULT", "defaultvalues").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
40 "defaultvalues"
41 );
42 config.setstrrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]setstr().("DEFAULT", "defaultvalues", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
•43 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(envrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/env!!("CARGO_TARGET_TMPDIR"));
44 config.writerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]write().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output.ini"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
45 let map2 = config.clonerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini][Clone]clone().().loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output.ini"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
46 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map2, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().config.get_map_refrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_map_ref().());
47 let map3 = config.clonerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini][Clone]clone().().readrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]read().(config.writesrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]writes().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
48 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map2, map3);
49 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.sectionsrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]sections().().lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 4);
50 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("DEFAULT", "defaultvalues"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
51 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
52 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "KFC").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
53 "the secret herb is orega-"
54 );
55 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "Empty string").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "");
56 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "None string"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
57 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("spacing", "indented").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "indented");
58 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
59 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("spacing", "not indented").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
60 "not indented"
61 );
62 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
63 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "colon").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
64 "value after colon"
65 );
66 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(config.getboolrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getbool().("values", "Bool")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
67 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().config.getboolcoercerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getboolcoerce().("values", "Boolcoerce")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
68 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getintrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getint().("values", "Int")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().31415);
69 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getuintrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getuint().("values", "Uint")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), 31415);
70 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getfloatrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getfloat().("values", "Float")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), 3.1415);
71 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getfloatrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getfloat().("topsecret", "None string"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#));
72 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
73 map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."default"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."defaultvalues"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
74 "defaultvalues"
75 );
76 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
77 map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."topsecret"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."kfc"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
78 "the secret herb is orega-"
79 );
80 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."topsecret"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."empty string"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "");
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."topsecret"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."none string"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
82 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."spacing"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."indented"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "indented");
83 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
84 map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."spacing"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."not indented"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
85 "not indented"
86 );
87 let mut config2 = config.clonerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini][Clone]clone().();
88 let val = config2.remove_keyrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]remove_key().("default", "defaultvalues");
89 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(val, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#));
90 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config2.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "defaultvalues"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
91 config2.remove_sectionrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]remove_section().("default");
92 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config2.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "nope"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
93 let mut_map = config.get_mut_maprust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_mut_map().();
94 mut_map.get_mutrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]get_mut().("topsecret").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().insertrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]insert().(
95 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("none string"),
96 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("None string")),
97 );
98 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
99 mut_map[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()."topsecret"]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."none string"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
100 "None string"
101 );
102 mut_map.clearrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]clear().();
103 config2.clearrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]clear().();
104 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.get_map_refrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_map_ref().(), config2.get_map_refrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_map_ref().());
105
106 config.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
107 config.read_and_appendrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]read_and_append().("defaultvalues=somenewvalue".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
108 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
109 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "defaultvalues").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
110 "somenewvalue"
111 );
112 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
113 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "KFC").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
114 "the secret herb is orega-"
115 );
116
117 let mut config3 = config.clonerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini][Clone]clone().();
118 let mut_map = config3.get_mut_maprust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_mut_map().();
119 mut_map.clearrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]clear().();
120 config3.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
121 config3.load_and_appendrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load_and_append().("tests/test_more.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
122 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
123 config3.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "defaultvalues").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
124 "overwritten"
125 );
126 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config3.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "KFC").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "redacted");
127 // spacing -> indented exists in tests/test.ini, but not tests/test_more.ini
128 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config3.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("spacing", "indented").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "indented");
129 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config3.getboolrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getbool().("values", "Bool")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), false);
130
131 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
132 }
133
134 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
135 #[allow(clippy::approx_constant)]
136 fn csrust-analyzer cargo configparser 3.0.3 cs().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
•137 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
138 let mut config = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::new_csrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new_cs().();
139 let map = config.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
140 config.set_comment_symbolsrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]set_comment_symbols().(&[';', '#', '!']);
141 let inpstring = config.readrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]read().(
142 "defaultvalues=defaultvalues
143 [topsecret]
144 KFC = the secret herb is orega-
145 colon:value after colon
146 Empty string =
147 None string
148 Password=[in-brackets]
149 [ spacing ]
150 indented=indented
151 not indented = not indented ;testcomment
152 !modified comment
153 [values]#another comment
154 Bool = True
155 Boolcoerce = 0
156 Int = -31415
157 Uint = 31415
158 Float = 3.1415"
159 .to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().(),
160 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
161 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map, inpstring);
162 config.setrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]set().("default", "defaultvalues", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("notdefault".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().()));
163 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
164 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "defaultvalues").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
165 "notdefault"
166 );
167 config.setstrrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]setstr().("default", "defaultvalues", Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("defaultvalues"));
168 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
169 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "defaultvalues").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
170 "defaultvalues"
171 );
172 config.setstrrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]setstr().("default", "defaultvalues", Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
•173 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(envrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/env!!("CARGO_TARGET_TMPDIR"));
174 config.writerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]write().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output2.ini"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
175 let map2 = config.clonerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini][Clone]clone().().loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output2.ini"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
176 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map2, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().config.get_map_refrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_map_ref().());
177 let map3 = config.clonerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini][Clone]clone().().readrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]read().(config.writesrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]writes().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
178 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map2, map3);
179 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.sectionsrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]sections().().lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 4);
180 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "defaultvalues"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
181 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
182 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "KFC").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
183 "the secret herb is orega-"
184 );
185 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "Empty string").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "");
186 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "None string"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
187 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("spacing", "indented").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "indented");
188 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
189 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("spacing", "not indented").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
190 "not indented"
191 );
192 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
193 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("topsecret", "colon").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
194 "value after colon"
195 );
196 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(config.getboolrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getbool().("values", "Bool")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
197 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().config.getboolcoercerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getboolcoerce().("values", "Boolcoerce")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
198 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getintrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getint().("values", "Int")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i64][Neg]neg().31415);
199 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getuintrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getuint().("values", "Uint")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), 31415);
200 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getfloatrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getfloat().("values", "Float")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch()..unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), 3.1415);
201 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getfloatrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]getfloat().("topsecret", "None string"), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#));
202 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
203 map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."default"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."defaultvalues"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
204 "defaultvalues"
205 );
206 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
207 map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."topsecret"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."KFC"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
208 "the secret herb is orega-"
209 );
210 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."topsecret"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."Empty string"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "");
211 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."topsecret"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."None string"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()., Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
212 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."spacing"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."indented"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "indented");
213 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
214 map[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."spacing"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."not indented"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
215 "not indented"
216 );
217 let mut config2 = config.clonerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini][Clone]clone().();
218 let val = config2.remove_keyrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]remove_key().("default", "defaultvalues");
219 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(val, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#));
220 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config2.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "defaultvalues"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
221 config2.remove_sectionrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]remove_section().("default");
222 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config2.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("default", "nope"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
223 let mut_map = config.get_mut_maprust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_mut_map().();
224 mut_map.get_mutrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]get_mut().("topsecret").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().insertrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]insert().(
225 Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("none string"),
226 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("None string")),
227 );
228 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
229 mut_map[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()."topsecret"]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().[rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()."none string"]rust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`][`Index<&Q>`]index()..clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`][Clone]clone().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
230 "None string"
231 );
232 mut_map.clearrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]clear().();
233 config2.clearrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]clear().();
234 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.get_map_refrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_map_ref().(), config2.get_map_refrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_map_ref().());
235 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
236 }
237
238 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
239 #[cfg(feature = "indexmap")]
240 fn sort_on_writerust-analyzer cargo configparser 3.0.3 sort_on_write().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
241 let mut config = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::new_csrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new_cs().();
242 config.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
243
244 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
245 config.writesrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]writes().(),
246 "defaultvalues=defaultvalues
247 [topsecret]
248 KFC=the secret herb is orega-
249 colon=value after colon
250 Empty string=
251 None string
252 Password=[in-brackets]
253 [spacing]
254 indented=indented
255 not indented=not indented
256 [values]
257 Bool=True
258 Boolcoerce=0
259 Int=-31415
260 Uint=31415
261 Float=3.1415
262 "
263 );
264
265 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
266 }
267
268 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
269 #[cfg(feature = "async-std")]
270 fn async_load_writerust-analyzer cargo configparser 3.0.3 async_load_write().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
•271 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#;
272 const OUT_FILE_CONTENTSrust-analyzer cargo configparser 3.0.3 OUT_FILE_CONTENTS.: &str = "defaultvalues=defaultvalues
273 [topsecret]
274 KFC = the secret herb is orega-
275 colon:value after colon
276 Empty string =
277 None string
278 Password=[in-brackets]
279 [ spacing ]
280 indented=indented
281 not indented = not indented ;testcomment
282 !modified comment
283 [values]#another comment
284 Bool = True
285 Boolcoerce = 0
286 Int = -31415
287 Uint = 31415
288 Float = 3.1415";
289
290 let mut config = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::newrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new().();
291 config.readrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]read().(OUT_FILE_CONTENTSrust-analyzer cargo configparser 3.0.3 OUT_FILE_CONTENTS..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
•292 let path = PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(envrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/env!!("CARGO_TARGET_TMPDIR"));
293 config.writerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]write().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output_sync.ini"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
294
295 async_stdrust-analyzer cargo async-std 1.13.2 crate/::taskrust-analyzer cargo async-std 1.13.2 task/::block_onrust-analyzer cargo async-std 1.13.2 task/block_on/block_on().::<_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<_, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(async {
296 let mut config_async = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::newrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new().();
297 config_async.readrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]read().(OUT_FILE_CONTENTSrust-analyzer cargo configparser 3.0.3 OUT_FILE_CONTENTS..to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
298 config_async
•299 .write_asyncrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]write_async().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output_async.ini"))
300 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().
301 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| e.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
302 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
303 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
304
305 let mut sync_content = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::newrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new().();
•306 sync_content.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output_sync.ini"))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
307
308 let async_content = async_stdrust-analyzer cargo async-std 1.13.2 crate/::taskrust-analyzer cargo async-std 1.13.2 task/::block_onrust-analyzer cargo async-std 1.13.2 task/block_on/block_on().::<_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<_, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(async {
309 let mut async_content = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::newrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new().();
•310 async_content.load_asyncrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load_async().(path.joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("output_async.ini")).rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
311 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(async_content)
312 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
313
314 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sync_content, async_content);
315
316 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
317 }
318
319 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
320 #[cfg(feature = "async-std")]
321 fn async_load_and_appendrust-analyzer cargo configparser 3.0.3 async_load_and_append().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
322 let mut sync_content = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::newrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new().();
323 sync_content.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
324 sync_content.load_and_appendrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load_and_append().("tests/test_more.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
325
326 let async_content = async_stdrust-analyzer cargo async-std 1.13.2 crate/::taskrust-analyzer cargo async-std 1.13.2 task/::block_onrust-analyzer cargo async-std 1.13.2 task/block_on/block_on().::<_, Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<_, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(async {
327 let mut async_content = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::newrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new().();
328 async_content.load_asyncrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load_async().("tests/test.ini").rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
329 async_content
330 .load_and_append_asyncrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load_and_append_async().("tests/test_more.ini")
331 .rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
332 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(async_content)
333 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
334
335 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(sync_content, async_content);
336
337 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
338 }
339
340 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
341 #[cfg(feature = "indexmap")]
342 fn multiline_offrust-analyzer cargo configparser 3.0.3 multiline_off().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
343 let mut config = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::new_csrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new_cs().();
344 config.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test_multiline.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
345
346 let map = config.get_map_refrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get_map_ref().();
347
348 let section = map.getrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]get().("Section").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
349
350 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key1").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "Value1");
351 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key2").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "Value Two");
352 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key3").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "this is a haiku");
353 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(section.contains_keyrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]contains_key().("spread across separate lines"));
354 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(section.contains_keyrust-analyzer cargo indexmap 2.14.0 map/impl#[`IndexMap<K, V, S>`]contains_key().("a single value"));
355
356 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key4").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "Four");
357
358 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
359 config.writesrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]writes().(),
360 "[Section]
361 Key1=Value1
362 Key2=Value Two
363 Key3=this is a haiku
364 spread across separate lines
365 a single value
366 Key4=Four
367 "
368 );
369
370 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
371 }
372
373 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
374 #[cfg(feature = "indexmap")]
375 fn multiline_onrust-analyzer cargo configparser 3.0.3 multiline_on().() -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#>> {
376 let mut config = Inirust-analyzer cargo configparser 3.0.3 ini/Ini#::new_csrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]new_cs().();
377 config.set_multilinerust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]set_multiline().(true);
378 config.loadrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]load().("tests/test_multiline.ini")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
379
380 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key1").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "Value1");
381 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key2").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "Value Two");
382 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
383 config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key3").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(),
384 "this is a haiku\nspread across separate lines\na single value"
385 );
386 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(config.getrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]get().("Section", "Key4").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), "Four");
387
388 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
389 config.writesrust-analyzer cargo configparser 3.0.3 ini/impl#[Ini]writes().(),
390 "[Section]
391 Key1=Value1
392 Key2=Value Two
393 Key3=this is a haiku
394 spread across separate lines
395 a single value
396 Key4=Four
397 "
398 );
399
400 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
401 }