dotenvy icon indicating copy to clipboard operation
dotenvy copied to clipboard

`Iter` type being leaked publicly

Open sonro opened this issue 2 years ago • 4 comments

The public functions dotenv_iter, from_read_iter, from_filename_iter, and from_path_iter all return the Iter struct - which is currently not public. It needs to be so users have easier to access its documentation.

As a public type it needs to eagerly implement common traits (Rust API Guidelines) and have decent documentation.

Its naming could also be improved. It is clear enough in the context of a library internal, but when constructed and viewed externally Iter is fairly nebulous. Are there any renaming suggestions?

Making Iter public would also make from_read_iter obsolete as all it does is call Iter::new.

sonro avatar Dec 06 '22 23:12 sonro

Naming: Iter is fine, since it is namespaced by the crate. See also https://docs.rs/error-chain/latest/error_chain/struct.Iter.html

There is only one kind of Iter in this crate, and the crate focuses on a single functionality.

LeoniePhiline avatar Dec 07 '22 23:12 LeoniePhiline

Making Iter public sounds good to me.

I would keep from_read_iter around, at least for the time being.

allan2 avatar Dec 10 '22 20:12 allan2

So pub use iter::Iter in the root namespace? (I'd rather not pub mod iter, as the nested namespace is useless to library users.)

LeoniePhiline avatar Dec 11 '22 17:12 LeoniePhiline

I am leaving this issue unresolved until the documentation for the type has been written. Thank you @LeoniePhiline for the starter PR.

sonro avatar Dec 14 '22 14:12 sonro

On the v0.16 branch, I have made Iter private. The *_iter functions are now deprecated. EnvLoader::load returns HashMap.

Does anyone object to Iter being private?

allan2 avatar Sep 04 '24 05:09 allan2