Skip to content

Commit

Permalink
📦 Ready for 2.0.1 and fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
QEDK committed Apr 5, 2021
1 parent 85a4d04 commit 90d10f9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "configparser"
version = "2.0.0"
version = "2.0.1"
authors = ["QEDK <qedk.en@gmail.com>"]
edition = "2018"
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."
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ strings as well as files.
You can install this easily via `cargo` by including it in your `Cargo.toml` file like:
```TOML
[dependencies]
configparser = "2.0.0"
configparser = "2.0.1"
```

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

### 🔜 Future plans

Expand Down
20 changes: 11 additions & 9 deletions src/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub struct Ini {
case_sensitive: bool,
}


///The `IniDefault` struct serves as a template to create other `Ini` objects from. It can be used to store and load
///default properties from different `Ini` objects.
///## Example
Expand All @@ -31,7 +30,7 @@ pub struct Ini {
///
///let mut config = Ini::new();
///let default = config.defaults();
///let mut config2 = Ini::new_from_defaults(default);
///let mut config2 = Ini::new_from_defaults(default); // default gets consumed
///```
#[derive(Debug, Clone, Eq, PartialEq, Default)]
pub struct IniDefault {
Expand Down Expand Up @@ -92,9 +91,11 @@ impl Ini {
/// delimiters: vec!['='],
/// case_sensitive: true,
///};
///let mut config = Ini::new_from_defaults(default);
///let mut config = Ini::new_from_defaults(default.clone());
///// Now, load as usual with new defaults:
///let map = config.load("tests/test.ini").unwrap();
///assert_eq!(config.defaults(), default);
///assert_eq!(config.defaults(), config.defaults());
///
///```
pub fn new_from_defaults(defaults: IniDefault) -> Ini {
Expand All @@ -115,12 +116,12 @@ impl Ini {
///let mut config = Ini::new();
///let default = config.defaults();
///```
///Returns an `IniDefault` object.
pub fn defaults(self) -> IniDefault {
///Returns an `IniDefault` object. Keep in mind that it will get borrowed since it has non-`Copy` types.
pub fn defaults(&self) -> IniDefault {
IniDefault {
default_section: self.default_section,
comment_symbols: self.comment_symbols,
delimiters: self.delimiters,
default_section: self.default_section.to_owned(),
comment_symbols: self.comment_symbols.to_owned(),
delimiters: self.delimiters.to_owned(),
case_sensitive: self.case_sensitive,
}
}
Expand All @@ -139,7 +140,8 @@ impl Ini {
/// delimiters: vec!['=', ':'],
/// case_sensitive: true,
///}; // This is equivalent to ini_cs() defaults
///config.load_defaults(default);
///config.load_defaults(default.clone());
///assert_eq!(config.defaults(), default);
///```
///Returns nothing.
pub fn load_defaults(&mut self, defaults: IniDefault) {
Expand Down

0 comments on commit 90d10f9

Please sign in to comment.