Skip to main content

bind_associative

Function bind_associative 

Source
pub fn bind_associative(
    pattern: &[Form],
    val: &Value,
    env: &mut Env,
) -> EvalResult<()>
Expand description

Bind a map destructuring pattern against val in env.

pattern is a flat [key val key val ...] slice from FormKind::Map.

Supports:

  • :keys [a b c] — bind symbols from keyword keys :a, :b, :c
  • :strs [a b] — bind symbols from string keys "a", "b"
  • :syms [a b] — bind symbols from symbol keys 'a, 'b
  • :as name — bind the whole value to name
  • :or {a default} — default value for missing keys
  • Regular {sym :key} direct bindings