Skip to content

Commit 90d10f9

Browse files
committed
📦 Ready for 2.0.1 and fix bugs
1 parent 85a4d04 commit 90d10f9

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "configparser"
3-
version = "2.0.0"
3+
version = "2.0.1"
44
authors = ["QEDK <[email protected]>"]
55
edition = "2018"
66
description = "A simple configuration parsing utility with no dependencies that allows you to parse INI and ini-style syntax. You can use this to write Rust programs which can be customized by end users easily."

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ strings as well as files.
2929
You can install this easily via `cargo` by including it in your `Cargo.toml` file like:
3030
```TOML
3131
[dependencies]
32-
configparser = "2.0.0"
32+
configparser = "2.0.1"
3333
```
3434

3535
## ➕ Supported datatypes
@@ -187,13 +187,16 @@ Old changelogs are in [CHANGELOG.md](CHANGELOG.md).
187187
- 0.13.2 (**FINAL BETA**)
188188
- Erroneous docs fixed.
189189
- Final release before stable.
190-
- 1.0.0 (**STABLE**)
190+
- 1.0.0
191191
- Dropped support for `ini::load()`
192192
- Updated tests
193193
- 2.0.0
194194
- **BREAKING** Added Python-esque support for `:` as a delimiter.
195195
- :new: Add support for case-sensitive maps with automatic handling under the hood.
196196
- :hammer: Fixed buggy setters which went uncaught, to preserve case-insensitive nature.
197+
- 2.0.1 (**STABLE**)
198+
- Add first-class support for setting, loading and reading defaults
199+
- New available struct `IniDefault` for fast templating
197200

198201
### 🔜 Future plans
199202

src/ini.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub struct Ini {
2222
case_sensitive: bool,
2323
}
2424

25-
2625
///The `IniDefault` struct serves as a template to create other `Ini` objects from. It can be used to store and load
2726
///default properties from different `Ini` objects.
2827
///## Example
@@ -31,7 +30,7 @@ pub struct Ini {
3130
///
3231
///let mut config = Ini::new();
3332
///let default = config.defaults();
34-
///let mut config2 = Ini::new_from_defaults(default);
33+
///let mut config2 = Ini::new_from_defaults(default); // default gets consumed
3534
///```
3635
#[derive(Debug, Clone, Eq, PartialEq, Default)]
3736
pub struct IniDefault {
@@ -92,9 +91,11 @@ impl Ini {
9291
/// delimiters: vec!['='],
9392
/// case_sensitive: true,
9493
///};
95-
///let mut config = Ini::new_from_defaults(default);
94+
///let mut config = Ini::new_from_defaults(default.clone());
9695
///// Now, load as usual with new defaults:
9796
///let map = config.load("tests/test.ini").unwrap();
97+
///assert_eq!(config.defaults(), default);
98+
///assert_eq!(config.defaults(), config.defaults());
9899
///
99100
///```
100101
pub fn new_from_defaults(defaults: IniDefault) -> Ini {
@@ -115,12 +116,12 @@ impl Ini {
115116
///let mut config = Ini::new();
116117
///let default = config.defaults();
117118
///```
118-
///Returns an `IniDefault` object.
119-
pub fn defaults(self) -> IniDefault {
119+
///Returns an `IniDefault` object. Keep in mind that it will get borrowed since it has non-`Copy` types.
120+
pub fn defaults(&self) -> IniDefault {
120121
IniDefault {
121-
default_section: self.default_section,
122-
comment_symbols: self.comment_symbols,
123-
delimiters: self.delimiters,
122+
default_section: self.default_section.to_owned(),
123+
comment_symbols: self.comment_symbols.to_owned(),
124+
delimiters: self.delimiters.to_owned(),
124125
case_sensitive: self.case_sensitive,
125126
}
126127
}
@@ -139,7 +140,8 @@ impl Ini {
139140
/// delimiters: vec!['=', ':'],
140141
/// case_sensitive: true,
141142
///}; // This is equivalent to ini_cs() defaults
142-
///config.load_defaults(default);
143+
///config.load_defaults(default.clone());
144+
///assert_eq!(config.defaults(), default);
143145
///```
144146
///Returns nothing.
145147
pub fn load_defaults(&mut self, defaults: IniDefault) {

0 commit comments

Comments
 (0)