Open Code0x58 opened 2 months ago
I've found this useful as is, for formatting a large enumeration with attributes on the members. One issue I've bumped into was that this enumeration in particular uses Serde's untagged feature e.g.
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub enum StringyThingy {
Zoo,
#[serde(untagged)]
Other(String)
}
where Other must be at the end. That makes me think that it would be best to try working out some way of maintaining this. The most practical solution I can think of right now is to have some a way to stop the index from being changed, e.g. rustfmt::skip::sort
pub enum StringyThingy {
Zoo,
#[rustfmt::skip::sort]
#[serde(untagged)]
Other(String)
}
3422: add explicit
rustfmt::sort
attribute which causes case sensitive sortingThis does not raise if
rustfmt::sort
is applied in an unhandled place (e.g. struct, member, etc.), although that might be reasonable to pursue; at a glance,rustfmt::skip
does not appear to do that, which may be more reasonable given how it can reasonably apply to anything.TODO:
#[rustfmt::skip::sort]