Rundo
Rundo is a redo / undo library for rust which can auto generate undo op. Below is an example to use Rundo.
extern crate rundo;
use *;
Note the macro Point!
at the first line of main function, why not use Point {...}
? That because Rundo redefined origin Point type with the same shape, but support undo redo. You can use it as same as before, but to literal construct must use a same name macro replace.
You can access data or modify with Workspace.data
directly, like:
extern crate rundo;
use *;
The change wasn't captured automatic. Generally, change only between in begin_op
and end_op
will be captured. Like this example:
extern crate rundo;
use *;
Use get_mut
to access data, Rundo will auto help you capture the the changes.
extern crate rundo;
use *;
After point lifetime over, all change will be captured and generate an undo operator.
begin_op
and end_op
support nested use. This will work:
space.begin_op();
// do some change here
space.begin_op();
// do some change here
space.begin_op();
// do some change here
space.end_op();
space.end_op();
space.end_op();
All change will be collected by the outer most pair begin_op/end_op
capture.