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. - Parse
Error - A parse error with span and structured error kind
Constants§
- VERSION
- Version of the
nixfmt_rscrate (and thus the formatting rules).
Functions§
- format
- Format a Nix file.
- format_
error - Render a
ParseErroras a multi-line diagnostic with source snippet and caret, in the style of rustc. - format_
with - Format a Nix file with explicit layout
Options.