Crates.io | nofmt |
lib.rs | nofmt |
version | 1.0.0 |
source | src |
created_at | 2021-05-14 20:53:11.936038 |
updated_at | 2021-05-14 20:53:11.936038 |
description | This crate provides `nofmt::pls`, a macro that does its best at preventing a code block from being mangled. |
homepage | |
repository | https://github.com/hquil/nofmt/ |
max_upload_size | |
id | 397563 |
size | 5,939 |
This crate provides nofmt::pls
, a macro that does its best at preventing a code block from being mangled.
[dependencies]
nofmt = "1.0"
nofmt::pls! {
// R G B A
pub const MAIN_WINDOW_BG: [f32; 4] = [0.187, 0.187, 0.187, 1. ];
pub const DEBUG_WINDOW_BG: [f32; 4] = [0. , 0. , 0. , 0.85];
pub const INPUT_BOX_BG: [f32; 4] = [0.011, 0.022, 0.055, 1. ];
}
Executing cargo fmt
on a crate is likely to violently alter every file, irreversibly. So our only option is to just go with it.
#[rustfmt::skip]
nofmt::pls!
#![cfg_attr(rustfmt, rustfmt_skip)]
Keep in mind that opting out of rustfmt can not be done through rustfmt.toml
.
Since both disable_all_formatting = true
and ignore = ["/"]
are not stable features.
By itself, this method is not perfect, inside of a nofmt::pls
block:
Note that format macros for rustfmt is an open issue. So this crate might stop working at any point in time.
To bypass the limitations, you can use the rustfmt::skip
attribute in conjunction with the the macro.
#[rustfmt::skip] nofmt::pls! {
let absolute_preservation_of_whitespace = "achieved";
}