This repository was archived by the owner on Dec 20, 2025. It is now read-only.
Open
Conversation
jsirois
commented
Nov 4, 2023
| use std::io; | ||
|
|
||
| #[derive(Debug)] | ||
| #[non_exhaustive] |
Author
There was a problem hiding this comment.
Thanks for this! I did not know about non_exhaustive until this change and it is what allowed this PR's conservative approach of not breaking existing users / requiring a major semver bump.
Refactor `dotenv::dotenv::Iter` to expose parse errors for those
interested. The parse errors are structured as opaque strings to hide
the parsing implementation details (currently nom and nom's errors are
the internal currency).
This allows a consumer that cares about propagating errors in `.env`
files to use something like:
```
let env = dotenv::from_filename(".env")?;
let mut iter = env.iter();
while let Some((key, value)) = iter.try_next()? {
if std::env::var(key).is_err() {
std::env::set_var(key, value);
}
}
```
Fixes arniu#4
jsirois
commented
Nov 4, 2023
| EXPAND_NEWLINES="expand\nnew\nlines" | ||
| DONT_EXPAND_UNQUOTED=dontexpand\nnewlines | ||
| DONT_EXPAND_SQUOTED='dontexpand\nnewlines' | ||
| DONT_EXPAND_SQUOTED='dontexpand\nnewlines' |
Author
There was a problem hiding this comment.
I assumed this duplicated line was unintentional (it was the only one in all the examples) and it got in the way of fixing tests to assert all expected values were observed. If this was intentional though, I can go back to work on handling this differently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactor
dotenv::dotenv::Iterto expose parse errors for thoseinterested. The parse errors are structured as opaque strings to hide
the parsing implementation details (currently nom and nom's errors are
the internal currency).
This allows a consumer that cares about propagating errors in
.envfiles to use something like:
Fixes #4