sum_tree: Do not implement Dimension on tuples, use new Dimensions wrapper instead (#35482)
This is a bit of a readability improvement IMHO; I often find myself confused when dealing when dimension pairs, as there's no easy way to jump to the implementation of a dimension for tuples to remind myself for the n-th time how exactly that impl works. Now it should be possible to jump directly to that impl. Another bonus is that Dimension supports 3-ary tuples as well - by using a () as a default value of a 3rd dimension. Release Notes: - N/A
This commit is contained in:
parent
be2f54b233
commit
07e3d53d58
18 changed files with 215 additions and 141 deletions
|
@ -16,7 +16,7 @@ use crate::{
|
|||
use collections::VecDeque;
|
||||
use refineable::Refineable as _;
|
||||
use std::{cell::RefCell, ops::Range, rc::Rc};
|
||||
use sum_tree::{Bias, SumTree};
|
||||
use sum_tree::{Bias, Dimensions, SumTree};
|
||||
|
||||
/// Construct a new list element
|
||||
pub fn list(state: ListState) -> List {
|
||||
|
@ -371,14 +371,14 @@ impl ListState {
|
|||
return None;
|
||||
}
|
||||
|
||||
let mut cursor = state.items.cursor::<(Count, Height)>(&());
|
||||
let mut cursor = state.items.cursor::<Dimensions<Count, Height>>(&());
|
||||
cursor.seek(&Count(scroll_top.item_ix), Bias::Right);
|
||||
|
||||
let scroll_top = cursor.start().1.0 + scroll_top.offset_in_item;
|
||||
|
||||
cursor.seek_forward(&Count(ix), Bias::Right);
|
||||
if let Some(&ListItem::Measured { size, .. }) = cursor.item() {
|
||||
let &(Count(count), Height(top)) = cursor.start();
|
||||
let &Dimensions(Count(count), Height(top), _) = cursor.start();
|
||||
if count == ix {
|
||||
let top = bounds.top() + top - scroll_top;
|
||||
return Some(Bounds::from_corners(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue