mirror of
https://github.com/OMGeeky/confique.git
synced 2026-01-06 03:29:37 +01:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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![],
|
||||
|
||||
Reference in New Issue
Block a user