Remove requirement of having either an example or a default value

It's fine not having either. We can just render `#key =` in the
template.
This commit is contained in:
Lukas Kalbertodt
2021-04-30 18:00:05 +02:00
parent c798049443
commit 0fcf36fd81
2 changed files with 6 additions and 11 deletions

View File

@@ -314,13 +314,13 @@ fn gen_toml(input: &Input) -> String {
}
}
// We check that already when parsing.
let example = example.as_ref()
.or(default.as_ref())
.expect("neither example nor default");
// Commented out key and optional example.
match example.as_ref().or(default.as_ref()) {
Some(example) => writeln!(out, "#{} = {}", name, example).unwrap(),
None => writeln!(out, "#{} =", name).unwrap()
}
// Commented out example.
writeln!(out, "#{} = {}", name, example).unwrap();
add_empty_line(&mut out);
}
}

View File

@@ -94,11 +94,6 @@ impl Parse for Node {
})
.transpose()?;
if example.is_none() && default.is_none() {
let msg = "either a default value or an example value has to be specified";
return Err(Error::new(name.span(), msg));
}
Self {
doc,
attrs: vec![],