Vendor dependencies

This commit is contained in:
2026-08-01 16:11:49 +03:00
parent 7f139a0241
commit 6b5e7f0f8b
29706 changed files with 9575646 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
use similar::get_close_matches;
fn main() {
let words = vec![
"apple",
"appu",
"appal",
"apparitor",
"beer",
"beeb",
"beeline",
];
println!("{:?}", get_close_matches("app", &words, 3, 0.7));
println!("{:?}", get_close_matches("bee", &words, 3, 0.7));
}
+8
View File
@@ -0,0 +1,8 @@
use similar::TextDiff;
fn main() {
let x = "abc".repeat(2000);
let y = "abd".repeat(2000);
let diff = TextDiff::from_chars(&x, &y);
println!("{}", diff.unified_diff());
}
+13
View File
@@ -0,0 +1,13 @@
use similar::{capture_diff_slices, Algorithm};
fn main() {
let old = vec![1, 2, 3];
let new = vec![1, 2, 4];
let ops = capture_diff_slices(Algorithm::Myers, &old, &new);
for op in ops {
for change in op.iter_changes(&old, &new) {
println!("{:?}", change);
}
}
}
@@ -0,0 +1,11 @@
use similar::utils::diff_chars;
use similar::Algorithm;
fn main() {
let old = "1234567890abcdef".to_string();
let new = "0123456789Oabzdef".to_string();
for (change_tag, value) in diff_chars(Algorithm::Myers, &old, &new) {
println!("{}{:?}", change_tag, value);
}
}
+48
View File
@@ -0,0 +1,48 @@
use similar::{Algorithm, TextDiff};
const OLD: &str = r#"
[
(
Major,
2,
),
(
Minor,
20,
),
(
Value,
0,
),
]
"#;
const NEW: &str = r#"
[
(
Major,
2,
),
(
Minor,
0,
),
(
Value,
0,
),
(
Value,
1,
),
]
"#;
fn main() {
println!(
"{}",
TextDiff::configure()
.algorithm(Algorithm::Patience)
.diff_lines(OLD, NEW)
.unified_diff()
);
}
+15
View File
@@ -0,0 +1,15 @@
use similar::TextDiff;
fn main() {
let diff = TextDiff::from_lines(
"Hello World\nThis is the second line.\nThis is the third.",
"Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more",
);
let all_changes = diff
.ops()
.iter()
.flat_map(|op| diff.iter_changes(op))
.collect::<Vec<_>>();
println!("{}", serde_json::to_string_pretty(&all_changes).unwrap());
}
@@ -0,0 +1,60 @@
use std::fmt;
use std::fs::read;
use std::process::exit;
use console::{style, Style};
use similar::{ChangeTag, TextDiff};
struct Line(Option<usize>);
impl fmt::Display for Line {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self.0 {
None => write!(f, " "),
Some(idx) => write!(f, "{:<4}", idx + 1),
}
}
}
fn main() {
let args: Vec<_> = std::env::args_os().collect();
if args.len() != 3 {
eprintln!("usage: terminal-inline [old] [new]");
exit(1);
}
let old = read(&args[1]).unwrap();
let new = read(&args[2]).unwrap();
let diff = TextDiff::from_lines(&old, &new);
for (idx, group) in diff.grouped_ops(3).iter().enumerate() {
if idx > 0 {
println!("{:-^1$}", "-", 80);
}
for op in group {
for change in diff.iter_inline_changes(op) {
let (sign, s) = match change.tag() {
ChangeTag::Delete => ("-", Style::new().red()),
ChangeTag::Insert => ("+", Style::new().green()),
ChangeTag::Equal => (" ", Style::new().dim()),
};
print!(
"{}{} |{}",
style(Line(change.old_index())).dim(),
style(Line(change.new_index())).dim(),
s.apply_to(sign).bold(),
);
for (emphasized, value) in change.iter_strings_lossy() {
if emphasized {
print!("{}", s.apply_to(value).underlined().on_black());
} else {
print!("{}", s.apply_to(value));
}
}
if change.missing_newline() {
println!();
}
}
}
}
}
+20
View File
@@ -0,0 +1,20 @@
use console::Style;
use similar::{ChangeTag, TextDiff};
fn main() {
let diff = TextDiff::from_lines(
"Hello World\nThis is the second line.\nThis is the third.",
"Hallo Welt\nThis is the second line.\nThis is life.\nMoar and more",
);
for op in diff.ops() {
for change in diff.iter_changes(op) {
let (sign, style) = match change.tag() {
ChangeTag::Delete => ("-", Style::new().red()),
ChangeTag::Insert => ("+", Style::new().green()),
ChangeTag::Equal => (" ", Style::new()),
};
print!("{}{}", style.apply_to(sign).bold(), style.apply_to(change));
}
}
}
+24
View File
@@ -0,0 +1,24 @@
use std::fs::read;
use std::io;
use std::process::exit;
use similar::TextDiff;
fn main() {
let args: Vec<_> = std::env::args_os().collect();
if args.len() != 3 {
eprintln!("usage: udiff [old] [new]");
exit(1);
}
let old = read(&args[1]).unwrap();
let new = read(&args[2]).unwrap();
TextDiff::from_lines(&old, &new)
.unified_diff()
.header(
&args[1].as_os_str().to_string_lossy(),
&args[2].as_os_str().to_string_lossy(),
)
.to_writer(io::stdout())
.unwrap();
}