1 unstable release

0.1.0 Dec 21, 2023

#1723 in Text processing

Download history 206/week @ 2024-11-16 112/week @ 2024-11-23 295/week @ 2024-11-30 190/week @ 2024-12-07 192/week @ 2024-12-14 89/week @ 2024-12-21 87/week @ 2024-12-28 337/week @ 2025-01-04 131/week @ 2025-01-11 116/week @ 2025-01-18 156/week @ 2025-01-25 143/week @ 2025-02-01 132/week @ 2025-02-08 72/week @ 2025-02-15 104/week @ 2025-02-22 134/week @ 2025-03-01

453 downloads per month

BlueOak-1.0.0

12KB
328 lines

detect-indent-rs Test

rust port of sindresorhus/detect-indent All attribution goes to that project.

Detect the indentation of code

Pass in a string of any kind of text and get the indentation.

Use cases

  • Persisting the indentation when modifying a file.
  • Have new content match the existing indentation.
  • Setting the right indentation in your editor.

Usage

Add this to your Cargo.toml

[dependencies]
detect-indent = "0.1"

and this to your crate root

extern crate detect_indent;
use detect_indent::detect_indent;

fn main() {
  println!("{:?}", detect_indent(""));
}

Algorithm

The current algorithm looks for the most common difference between two consecutive non-empty lines. More Details

Dependencies

~2–3MB
~53K SLoC