I currently have:
trait ListModel {
fn get_stuff(&self, row: i) -> Stuff;
...
}
struct List {
model: Rc<dyn ListModel>,
...
}
I think I want to change my model to use row IDs instead of usize indices. If I do this:
trait ListModel {
type Key: Eq + Hash + Clone;
fn get_stuff(&self, row: Key) -> Stuff;
}
There is no way to keep List non-generic, correct? I need to have something like these? :
struct List<M: ListModel> {
model: Rc<M>,
}
// or
struct List<K> {
model: Rc<dyn ListModel<Key = K>>,
...
}
3 posts - 3 participants
Read full topic
| # | Наименование новости | Тональность | Информативность | Дата публикации |
|---|---|---|---|---|
| 1 | Strategies for dyn trait objects with optional behavior? | 0 | 7.12 | 06-10-2026 |
| 2 | Why no Dependent Matrix Type? | 0 | 5.16 | 08-10-2026 |
| 3 | Type erasure and dyn lifetime in a NonNull/Box struct field | 0 | 8.55 | 04-10-2026 |
| 4 | Limitations of `min_specialization` when specializing a generic implementation? | 0 | 9.38 | 04-10-2026 |
| 5 | Crate async_trait - error future created by async block is not Send | 0 | 5.4 | 05-10-2026 |
| 6 | Arena's and alignment | 0 | 7.3 | 04-10-2026 |
| 7 | Optimization of inlined functions returning Result? | 0 | 7.36 | 06-10-2026 |
| 8 | Why is f32/f64::sqrt not const? | 0 | 22.72 | 06-10-2026 |
| 9 | What's everyone working on this week (41/2026)? | 0 | 20.34 | 06-10-2026 |
| 10 | Array initialization post declaration | 0 | 16.79 | 06-10-2026 |