From fe38ac72d2f5aa910e2a12415c60317ee2f0dc69 Mon Sep 17 00:00:00 2001 From: Daniel Griffen Date: Tue, 14 May 2019 13:41:30 -0700 Subject: [PATCH] deprecate `iter` methods --- dotenv/src/lib.rs | 6 +++++- dotenv/tests/test-dotenv-iter.rs | 1 + dotenv/tests/test-from-filename-iter.rs | 1 + dotenv/tests/test-from-path-iter.rs | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dotenv/src/lib.rs b/dotenv/src/lib.rs index 1707277..16837ad 100644 --- a/dotenv/src/lib.rs +++ b/dotenv/src/lib.rs @@ -79,7 +79,8 @@ pub fn vars() -> Vars { /// dotenv::from_path(my_path.as_path()); /// ``` pub fn from_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. @@ -99,6 +100,7 @@ pub fn from_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>(path: P) -> Result> { Ok(Iter::new(File::open(path).map_err(Error::Io)?)) } @@ -144,6 +146,7 @@ pub fn from_filename>(filename: P) -> Result { /// println!("{}={}", key, val); /// } /// ``` +#[deprecated(since = "0.14.1", note = "please use `from_path` in conjunction with `var` instead")] pub fn from_filename_iter>(filename: P) -> Result> { let (_, iter) = Finder::new().filename(filename.as_ref()).find()?; Ok(iter) @@ -174,6 +177,7 @@ pub fn dotenv() -> Result { /// println!("{}={}", key, val); /// } /// ``` +#[deprecated(since = "0.14.1", note = "please use `from_path` in conjunction with `var` instead")] pub fn dotenv_iter() -> Result> { let (_, iter) = Finder::new().find()?; Ok(iter) diff --git a/dotenv/tests/test-dotenv-iter.rs b/dotenv/tests/test-dotenv-iter.rs index 2892303..3fcc46b 100644 --- a/dotenv/tests/test-dotenv-iter.rs +++ b/dotenv/tests/test-dotenv-iter.rs @@ -6,6 +6,7 @@ use dotenv::*; use crate::common::*; #[test] +#[allow(deprecated)] fn test_dotenv_iter() { let dir = make_test_dotenv().unwrap(); diff --git a/dotenv/tests/test-from-filename-iter.rs b/dotenv/tests/test-from-filename-iter.rs index 97f8c25..cb1867b 100644 --- a/dotenv/tests/test-from-filename-iter.rs +++ b/dotenv/tests/test-from-filename-iter.rs @@ -6,6 +6,7 @@ use dotenv::*; use crate::common::*; #[test] +#[allow(deprecated)] fn test_from_filename_iter() { let dir = make_test_dotenv().unwrap(); diff --git a/dotenv/tests/test-from-path-iter.rs b/dotenv/tests/test-from-path-iter.rs index bdcb042..703825e 100644 --- a/dotenv/tests/test-from-path-iter.rs +++ b/dotenv/tests/test-from-path-iter.rs @@ -6,6 +6,7 @@ use dotenv::*; use crate::common::*; #[test] +#[allow(deprecated)] fn test_from_path_iter() { let dir = make_test_dotenv().unwrap();