Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict lifetimes of SectionSetter methods #135

Merged
merged 4 commits into from
Aug 2, 2024

Conversation

rikyborg
Copy link
Contributor

@rikyborg rikyborg commented Aug 2, 2024

Fixes #134

Allow both for chaining calls to set/add/delete, and for separate calls of those methods on the same SectionSetter variable:

        let mut ini = Ini::new();
        let mut section_setter = ini.with_section(Some("section"));

        // chained set() calls
        section_setter.set("a", "1").set("b", "2");
        // separate set() calls
        section_setter.set("c", "3");

The last call would previously raise a compiler error because section_setter was still mutably borrowed until it went out of scope.

Also, change get() method to take &self rather than &mut self.

@zonyitoo zonyitoo merged commit 35dc113 into zonyitoo:master Aug 2, 2024
6 checks passed
renovate bot added a commit to runtime-env/import-meta-env that referenced this pull request Aug 3, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rust-ini](https://togithub.com/zonyitoo/rust-ini) | dependencies |
patch | `0.21.0` -> `0.21.1` |

---

### Release Notes

<details>
<summary>zonyitoo/rust-ini (rust-ini)</summary>

###
[`v0.21.1`](https://togithub.com/zonyitoo/rust-ini/releases/tag/v0.21.1)

[Compare
Source](https://togithub.com/zonyitoo/rust-ini/compare/v0.21.0...v0.21.1)

#### What's Changed

- Deduplicate eof error handling by
[@&#8203;GnomedDev](https://togithub.com/GnomedDev) in
[zonyitoo/rust-ini#127
- [#&#8203;128](https://togithub.com/zonyitoo/rust-ini/issues/128)
Add/Allow duplicate properties by
[@&#8203;RouHim](https://togithub.com/RouHim) in
[zonyitoo/rust-ini#129
- Restrict lifetimes of SectionSetter methods by
[@&#8203;rikyborg](https://togithub.com/rikyborg) in
[zonyitoo/rust-ini#135

#### New Contributors

- [@&#8203;RouHim](https://togithub.com/RouHim) made their first
contribution in
[zonyitoo/rust-ini#129
- [@&#8203;rikyborg](https://togithub.com/rikyborg) made their first
contribution in
[zonyitoo/rust-ini#135

**Full Changelog**:
zonyitoo/rust-ini@v0.21.0...v0.21.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View the
[repository job
log](https://developer.mend.io/github/runtime-env/import-meta-env).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@rikyborg rikyborg deleted the setter-lifetimes branch August 7, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to call SectionSetter::set again due to too-restrictive lifetimes on method signature
2 participants