Skip to main content

unsupported_section

Function unsupported_section 

Source
pub fn unsupported_section(template: &str) -> Result<Option<&str>, &'static str>
Expand description

The first placeholder in a template that names no section, if there is one.

The check a spec is held to wherever one is written down: KDL refuses a template at parse and the derive refuses one at compile time, so a page is never rendered from a template whose sections cannot all be filled. Err reports an opening {{ with no }} after it, which is a typo rather than a section name.

use usage_argv::help::unsupported_section;

assert_eq!(unsupported_section("{{about}}{{usage}}"), Ok(None));
assert_eq!(unsupported_section("{{ options }}"), Ok(Some("options")));
assert!(unsupported_section("{{usage").is_err());