Implement the collection traits on Exchange #6

Closed
opened 2026-08-14 21:12:56 +00:00 by rosa · 0 comments
Owner

Exchange is a keyed collection of rates, but implements none of the traits Rust
collections are expected to carry. MoneyBag in src/bag.rs already establishes
what this should look like in this crate; Exchange has none of it.

Missing:

  • FromIterator<ExchangeRate> — a sequence of quotes cannot be collect()ed into a table.
  • Extend<ExchangeRate> and Extend<&ExchangeRate>.
  • IntoIterator for Exchange and &Exchange.
  • quotes() should be iter(). C-ITER asks that the method yielding a
    collection's elements be named iter, and MoneyBag::iter (src/bag.rs:209)
    already follows it.
  • A named iterator type instead of impl ExactSizeIterator. C-ITER-TY asks for
    one, bag.rs names Balances / IntoBalances, and naming it is what makes
    room for DoubleEndedIterator and FusedIterator — both supported by the
    underlying btree_map::Iter and both exposed by Balances
    (src/bag.rs:383-395). Today a table cannot be walked in reverse.

Guidelines: C-COLLECT, C-ITER, C-ITER-TY.

`Exchange` is a keyed collection of rates, but implements none of the traits Rust collections are expected to carry. `MoneyBag` in `src/bag.rs` already establishes what this should look like in this crate; `Exchange` has none of it. Missing: - `FromIterator<ExchangeRate>` — a sequence of quotes cannot be `collect()`ed into a table. - `Extend<ExchangeRate>` and `Extend<&ExchangeRate>`. - `IntoIterator` for `Exchange` and `&Exchange`. - `quotes()` should be `iter()`. C-ITER asks that the method yielding a collection's elements be named `iter`, and `MoneyBag::iter` (`src/bag.rs:209`) already follows it. - A named iterator type instead of `impl ExactSizeIterator`. C-ITER-TY asks for one, `bag.rs` names `Balances` / `IntoBalances`, and naming it is what makes room for `DoubleEndedIterator` and `FusedIterator` — both supported by the underlying `btree_map::Iter` and both exposed by `Balances` (`src/bag.rs:383-395`). Today a table cannot be walked in reverse. Guidelines: C-COLLECT, C-ITER, C-ITER-TY.
rosa closed this issue 2026-08-14 21:27:39 +00:00
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rosa/lucre#6
No description provided.