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

Implement ExactSizeIterator for ParamsIter or Index for Params #53

Closed
Totodore opened this issue Jun 13, 2024 · 1 comment
Closed

Implement ExactSizeIterator for ParamsIter or Index for Params #53

Totodore opened this issue Jun 13, 2024 · 1 comment

Comments

@Totodore
Copy link
Contributor

Knowing the exact remaining length of the iterator would be nice in my use case, I'm deserializing params to T with serde and I need to keep track of the remaining length.

Because ParamsIter only wraps an std::slice::Iter, and that it already implements ExactSizeIterator we just have to forward the call to the inner Iter.

Another way to solve my issue would have been to directly use Params but I cannot access any elements because it doesn't implement Index.

What is your opinion on this @ibraheemdev? If you are ok with any of these two solution I will be happy to implement them.

@ibraheemdev
Copy link
Owner

ibraheemdev commented Jun 26, 2024

Implementing ExactSizeIterator seems reasonable. I would prefer to avoid making Params indexable by usize to allow, for example, switching the underlying representation to be HashMap<&str, &str> without a breaking change.

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

No branches or pull requests

2 participants