john-slop/examples/plan_replacements.rs

19 lines
602 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//! Inspect the edits shared by detector, formatter, and future LSP adapters.
use john_slop::{Config, apply_replacements, plan_replacements};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let source = "Review—then subtract 5−2.";
let edits = plan_replacements(&Config::embedded(), source);
println!("source: {source}");
for edit in &edits {
println!(
"replace bytes {}..{} with {:?}",
edit.byte_span.start, edit.byte_span.end, edit.replacement
);
}
println!("result: {}", apply_replacements(source, &edits)?);
Ok(())
}