pub struct Diff { /* private fields */ }
Expand description
Represents a series of operations that were performed on a file to transform it into a new version.
The operations are stored in file order, which means that every operation that affects an earlier part of the file must be stored before an operation that affects a later part. The diff also assumes that insert operations are performed prior to delete operations.
Implementations§
Source§impl Diff
impl Diff
Sourcepub fn apply_to_string(&self, string: &str) -> Result<String, FromUtf8Error>
pub fn apply_to_string(&self, string: &str) -> Result<String, FromUtf8Error>
Applies all of the operations in the diff to the given string. Gives an error if the resulting string can’t be represented by utf8.
§Panics
When the operations refer to positions that are not represented by the string.
Sourcepub fn apply(&self, file: &mut File) -> Result<()>
pub fn apply(&self, file: &mut File) -> Result<()>
Apply the operations in this sequence to a file. This should not be called until after
the sequence has been integrated via Engine::integrate_remote
The file must have been opened on both read and write mode (see OpenOptions).