Skip to main content

render_growing

Function render_growing 

pub fn render_growing(dist: &Distribution, open: Option<&Open>) -> String
Expand description

Renders a distribution and its optional growth policy in the string DSL – the counterpart of parse_growing, and what makes its round trip expressible at all: Open is deliberately not part of Distribution, so Display alone cannot carry a policy.

render_growing(d, None) renders identically to d.to_string(). With Some(open), the base form renders exactly as Display would, followed by open/open=up/open=down (from Open::sides) and then limit=<n>../limit=..=<n> for whichever side of Open::limit_low/ Open::limit_high is set – the same order parse_growing accepts and the module documentation’s grammar table shows. factor and max_expansions never reach text (see the module documentation): they keep their defaults, reachable only from the Open builder in Rust.

use atune_core::space::{dsl, Distribution, Open};

let dist = Distribution::float_log(1e-5, 1e-2)?;
let open = Open::new(dist.clone()).up().limit(..=1.0);
assert_eq!(
    dsl::render_growing(&dist, Some(&open)),
    "loguniform(0.00001, 0.01, open=up, limit=..=1)"
);
assert_eq!(dsl::render_growing(&dist, None), dist.to_string());