Skip to main content

Crate nixfmt_rs

Crate nixfmt_rs 

Source
Expand description

nixfmt-rs: Rust implementation of nixfmt with exact Haskell compatibility.

§Example

let src = "{foo=1;}";
assert_eq!(nixfmt_rs::format(src).unwrap(), "{ foo = 1; }\n");

let mut opts = nixfmt_rs::Options::default();
opts.width = 40;
let _ = nixfmt_rs::format_with(src, &opts).unwrap();

On parse failure the returned ParseError can be rendered for users via format_error.

Macros§

format_constructor
Macro to format constructor applications.
format_enum
Macro to format enum match arms Automatically generates match arms that call format_constructor! for each variant
format_record
Macro to format record fields with comma separation Based on pretty-simple’s list function for Braces From Haskell: Braces xss -> list “{” “}” xss

Structs§

Options
Layout options for format_with.
ParseError
A parse error with span and structured error kind

Constants§

VERSION
Version of the nixfmt_rs crate (and thus the formatting rules).

Functions§

format
Format a Nix file.
format_error
Render a ParseError as a multi-line diagnostic with source snippet and caret, in the style of rustc.
format_with
Format a Nix file with explicit layout Options.