Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rust-diff

A diff library written in rust

Documentation

Example Usage

Calculate the diff

use diff::{diff, patch, pretty_print};
use std::io::stdout;

let from = vec!["this", "is", "an", "example"];
let to = vec!["this", "is", "another", "example"];

// generate the edit script
let changes = diff(&from, &to);

Each edit in the diff is represented by a DiffItem

Print the diff (gnu diff format)

for edit in &changes {
    print!("{}", *edit);
}

Apply a change specified by a DiffItem

// apply the first edit in the script
let patched = patch(&from, &changes[0]);

print out a colored representation of a single change

pretty_print(stdout(), &from, &changes[0]);

About

A diff library written in rust

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages