pub trait Incremental<T: Transformer>: Transformable + Into<T> {
    fn update(&self, to: &T, delta: &Self::Delta) -> T::Delta;
}
Expand description

A trait capturing the essence of an incremental computation from self to some item T. This is similar to the Into trait, but with the ability to work with deltas. To understand this, consider the following:

let t1 : T = self.into()
//
self.transform(&d1);
//
let t2 : T = self.into()

This assumes some delta d which can be applied to self. The issue with this is that the final transformation to t2 is computed from scratch. This could be expensive, though it might be necessary. However, for some computations, however, we can reduce the amount of work done by incrementally applying into through the delta d. That would look like this:

let t1 : T = self.into()
//
let d2 = self.update(&t1,&d1);
//
let t2 = t1.transform_into(&d2);

This update version produces the same t2 as the original, but allows for the computation to exploit existing information about t1. In some cases, this can make a big difference. For example, consider parsing algorithm which turns a source file into an Abstract Syntax Tree. In this case, a delta is some change to the source file. Then, given the AST for a source file and a change to that source file, the resulting AST might be almost entirely (or actually) the same as the original file. For example, if the change removed a line of whitespace then nothing changes.

Required Methods

Implementors