Skip to content

Commit

Permalink
deprecate iter methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ZoeyR committed May 14, 2019
1 parent 93cc5d6 commit fe38ac7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dotenv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ pub fn vars() -> Vars {
/// dotenv::from_path(my_path.as_path());
/// ```
pub fn from_path<P: AsRef<Path>>(path: P) -> Result<()> {
from_path_iter(path)?.load()
let iter = Iter::new(File::open(path).map_err(Error::Io)?);
iter.load()
}

/// Like `from_path`, but returns an iterator over variables instead of loading into environment.
Expand All @@ -99,6 +100,7 @@ pub fn from_path<P: AsRef<Path>>(path: P) -> Result<()> {
/// println!("{}={}", key, val);
/// }
/// ```
#[deprecated(since = "0.14.1", note = "please use `from_path` in conjunction with `var` instead")]
pub fn from_path_iter<P: AsRef<Path>>(path: P) -> Result<Iter<File>> {
Ok(Iter::new(File::open(path).map_err(Error::Io)?))
}
Expand Down Expand Up @@ -144,6 +146,7 @@ pub fn from_filename<P: AsRef<Path>>(filename: P) -> Result<PathBuf> {
/// println!("{}={}", key, val);
/// }
/// ```
#[deprecated(since = "0.14.1", note = "please use `from_path` in conjunction with `var` instead")]
pub fn from_filename_iter<P: AsRef<Path>>(filename: P) -> Result<Iter<File>> {
let (_, iter) = Finder::new().filename(filename.as_ref()).find()?;
Ok(iter)
Expand Down Expand Up @@ -174,6 +177,7 @@ pub fn dotenv() -> Result<PathBuf> {
/// println!("{}={}", key, val);
/// }
/// ```
#[deprecated(since = "0.14.1", note = "please use `from_path` in conjunction with `var` instead")]
pub fn dotenv_iter() -> Result<iter::Iter<File>> {
let (_, iter) = Finder::new().find()?;
Ok(iter)
Expand Down
1 change: 1 addition & 0 deletions dotenv/tests/test-dotenv-iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use dotenv::*;
use crate::common::*;

#[test]
#[allow(deprecated)]
fn test_dotenv_iter() {
let dir = make_test_dotenv().unwrap();

Expand Down
1 change: 1 addition & 0 deletions dotenv/tests/test-from-filename-iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use dotenv::*;
use crate::common::*;

#[test]
#[allow(deprecated)]
fn test_from_filename_iter() {
let dir = make_test_dotenv().unwrap();

Expand Down
1 change: 1 addition & 0 deletions dotenv/tests/test-from-path-iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use dotenv::*;
use crate::common::*;

#[test]
#[allow(deprecated)]
fn test_from_path_iter() {
let dir = make_test_dotenv().unwrap();

Expand Down

1 comment on commit fe38ac7

@mashedcode
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? What should I use if I would want to read a .env file and pass the variables to a process I spawn and keep the environment variables in the current process untouched?

Please sign in to comment.