Skip to main content

value_to_hcl

Function value_to_hcl 

Source
pub fn value_to_hcl(v: &Value) -> Value
Expand description

Convert our Value into the hcl::Value shape hcl::eval consumes.

Numeric handling:

  • Value::Inthcl::Number::from(i64) (no float widening).
  • Value::Numberhcl::Number::from_f64(f), with NaN / ±Inf collapsing to HclValue::Null because hcl::Number rejects them. The collapse is pinned by a unit test below; callers who care can pre-filter.

Strings / lists / maps are recursive; insertion order is preserved on Value::Map → hcl::Value::Object because hcl::Map is indexmap::IndexMap.