Skip to main content

parse_named

Function parse_named 

pub fn parse_named(entry: &str) -> Result<(String, Distribution)>
Expand description

Parses a single name = spec line into a name and its Distribution.

The name is everything before the first = (trimmed); the spec is the rest. A step= inside the spec is therefore never mistaken for the separator, because the name is a plain identifier that ends at the first =.

use atune_core::space::dsl;

let (name, dist) = dsl::parse_named("batch = int(16, 512, step=16)")?;
assert_eq!(name, "batch");
assert_eq!(dist, atune_core::space::Distribution::int_step(16, 512, 16)?);

ยงErrors

Error::InvalidSpace if there is no =, if the name is empty, or if the spec does not parse (the spec error is prefixed with the parameter name).