Skip to content

Commit

Permalink
Skip parsing empty config TOML doc
Browse files Browse the repository at this point in the history
  • Loading branch information
jplatte committed Dec 28, 2024
1 parent 3701753 commit 8063b2f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ impl Config {
impl FromStr for Config {
type Err = &'static str;
fn from_str(s: &str) -> Result<Self, Self::Err> {
if s.is_empty() {
return Ok(Self::new());
}

let toml = s.parse::<DocumentMut>().map_err(|_| "failed to parse as toml")?;
Ok(Config {
always_trailing_comma: toml
Expand Down

0 comments on commit 8063b2f

Please sign in to comment.