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

[kvdb-rocksdb] Give Database::iter a concrete type #437

Closed
maciejhirsz opened this issue Oct 29, 2020 · 3 comments
Closed

[kvdb-rocksdb] Give Database::iter a concrete type #437

maciejhirsz opened this issue Oct 29, 2020 · 3 comments

Comments

@maciejhirsz
Copy link

The return type on Database::iter in kvdb-rocksdb is impl Iterator<...>, which limits the usability of the iterator for downstream users, in particular we can't put it into an associated type for a trait and have to use a boxed iterator trait object instead.

It would be nice to have a public type alias for the concrete type, or a newtype wrapper around it to hide internals if necessary.

@ordian
Copy link
Member

ordian commented Oct 29, 2020

Thanks for bringing this up.

I'm however skeptical we should do this:

  1. It probably has zero impact on performance. iter is dominated by I/O, unless you call it in a loop and don't actually iterate, which is a very contrived scenario. I'd like to avoid breaking changes for no gain.
  2. I'm not sure it's possible to implement as a associated type, because the iterator type has a reference, so it seems to be blocked on GAT in Rust: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=bbf27237552047ffc86df9eee475c6e3.

I'm happy to be proven wrong on both points.

@maciejhirsz
Copy link
Author

It's doable with a trait impl on a ref with lifetime set, though that requires adding another trait and some pretty verbose extra trait bounds, which wouldn't be super pretty, so fair enough.

@ordian
Copy link
Member

ordian commented Feb 4, 2022

closing as wontfix since we're deprecating kvdb-rocksdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants