1 unstable release

0.1.0 Dec 21, 2023

#636 in Text processing

Download history 78/week @ 2023-12-18 14/week @ 2023-12-25 41/week @ 2024-01-01 123/week @ 2024-01-08 72/week @ 2024-01-15 38/week @ 2024-01-22 71/week @ 2024-01-29 58/week @ 2024-02-05 82/week @ 2024-02-12 57/week @ 2024-02-19 84/week @ 2024-02-26 47/week @ 2024-03-04 110/week @ 2024-03-11 81/week @ 2024-03-18 177/week @ 2024-03-25 125/week @ 2024-04-01

497 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.2–3MB
~54K SLoC