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 mut list = LocList::read_str(input, Language::Rust).unwrap();
list.sort_around_line_index(5).unwrap();
assert_eq!(list.to_string(), output);

Modules§

java
javascript
rust

Macros§

line_number
A macro to create a LineNumber from a literal

Structs§

BraceStack
CharSet
Focused
Gift
Something that can maybe satisfy a wish
LineNumber
A 1-based line number, as used in most text editors
LineNumberRange
A range of 1-based line numbers, both ends included
LineNumberRangeIter
Loc
A Line of Code, analyzed.
LocList
A list of Lines of Code
Wish
Something that is required by the state of a LOC list

Enums§

Analyzer
CsError
An error in codesort
Language
The language syntax to use for analyzing the code
Spacing
The kind of spacing between blocs

Functions§

char_is_brace

Type Aliases§

CsResult
LineIndex
A 0-based line index