pub struct Change<T> { /* private fields */ }Expand description
A change of a list (Change<T>): of one item, or of a range of items.
Upstream’s change of one item has an empty range (RangeChange<T>.Empty), and a change of a
range has an empty item (ItemChange<T>.Empty, whose item is the default value of T); here
range is empty for the change of an item, and the change of a range has no
item (try_item).
Implementations§
Source§impl<T> Change<T>
impl<T> Change<T>
Sourcepub fn new(reason: ListChangeReason, current: T, index: Option<usize>) -> Self
pub fn new(reason: ListChangeReason, current: T, index: Option<usize>) -> Self
The change of one item (Change(ListChangeReason, T, int index = -1)).
Sourcepub fn range_change(
reason: ListChangeReason,
items: Vec<T>,
index: Option<usize>,
) -> Self
pub fn range_change( reason: ListChangeReason, items: Vec<T>, index: Option<usize>, ) -> Self
The change of a range (Change(ListChangeReason, IEnumerable<T>, int index = -1)).
§Panics
For a reason of one item (IndexOutOfRangeException).
Sourcepub fn moved(current: T, current_index: usize, previous_index: usize) -> Self
pub fn moved(current: T, current_index: usize, previous_index: usize) -> Self
A move (Change(T, int currentIndex, int previousIndex)).
Sourcepub fn with_previous(
reason: ListChangeReason,
current: T,
previous: Option<T>,
current_index: Option<usize>,
previous_index: Option<usize>,
) -> Self
pub fn with_previous( reason: ListChangeReason, current: T, previous: Option<T>, current_index: Option<usize>, previous_index: Option<usize>, ) -> Self
The change of one item with every part (Change(ListChangeReason, T, in Optional<T>, int, int)).
§Panics
For Add with a previous item, Replace without one, and Refresh without an index
(ArgumentException).
Sourcepub fn reason(&self) -> ListChangeReason
pub fn reason(&self) -> ListChangeReason
The reason (Reason).
Sourcepub fn change_type(&self) -> ChangeType
pub fn change_type(&self) -> ChangeType
Whether the change is of an item or of a range (Type).
Sourcepub fn item(&self) -> &ItemChange<T>
pub fn item(&self) -> &ItemChange<T>
Sourcepub fn try_item(&self) -> Option<&ItemChange<T>>
pub fn try_item(&self) -> Option<&ItemChange<T>>
The change of the item, None for the change of a range.
Sourcepub fn range(&self) -> &RangeChange<T>
pub fn range(&self) -> &RangeChange<T>
The range (Range): empty for the change of an item.