What is the `diff` method in the Widget trait?

Hey! I’m new to Iced, and admittedly reading code in general, so apologies if there was some method that I was able to learn this without asking for help.

Anyways, I was wondering what the diff method in Widget is for? Looking at a random selection of examples and common widgets, most of them don’t seem to implement it at all. I was able to find one example use case in the toast example. There is a concept of the “old” and “new” (current?) state and it seems to arbitrarily modify the new state to somewhat match the old (matching the lengths of the two vectors, with no regards for their contents), though I can’t imagine why.

The doc comments mention “Reconciling the widget with the tree” though I also don’t understand why we might need to do this, or what reconciling in this case means.

I am currently learning about the API too and take some notes for expanding my guide.
I have not create a real custom widget yet and can not confirm that the following information is true. I researched it by looking at code and asking questions on the discord.

my notes so far on the diff method

This function compares/reconciles the old state Tree, with what you would expect it to be. If there should be something different, you change it in the given tree.

Often for widgets that contain other widgets it looks similar to this:

fn diff(&self, tree: &mut Tree) {
	tree.diff_children(&self.children);
}

It is useful to customize this when your state needs to be changed depending on the arguments of the new function. You might pass data into your new function which needs to be in the state of your widget.
Although this seems not to be the case that often.

In the research of this function I could not find a good example where this is clearly used and good to understand