Crate codesort

source ·
Expand description

codesort sorts code, either as a command line tool, usually integrated in an IDE or a text editor, or as a library.

use codesort::{LocList, Language};
let input = r#"
pub enum ContentSearchResult {
    /// the file wasn't searched because it's binary or too big
    NotSuitable,
    /// the needle has been found at the given pos
    Found {
        pos: usize,
    },
    /// the needle hasn't been found
    NotFound, // no match
}
"#;

let output = r#"
pub enum ContentSearchResult {
    /// the needle has been found at the given pos
    Found {
        pos: usize,
    },
    /// the needle hasn't been found
    NotFound, // no match
    /// the file wasn't searched because it's binary or too big
    NotSuitable,
}
"#;

let list = LocList::read_str(input, Language::Rust).unwrap();
let focused = list.focus_around_line_index(5).unwrap();
assert_eq!(
    focused.sort().to_string(),
    output,
);

Modules§

Structs§

Enums§

Functions§

Type Aliases§