Crates.io | detect-indent |
lib.rs | detect-indent |
version | 0.1.0 |
source | src |
created_at | 2023-12-21 17:41:14.386442 |
updated_at | 2023-12-21 17:41:14.386442 |
description | Detect the indentation of code |
homepage | |
repository | https://github.com/stefanpenner/detect-indent-rs |
max_upload_size | |
id | 1077289 |
size | 15,131 |
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.
Persisting the indentation when modifying a file.
Have new content match the existing indentation.
Setting the right indentation in your editor.
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(""));
}
The current algorithm looks for the most common difference between two consecutive non-empty lines. More Details