Skip to main content

split_env_string

Function split_env_string 

Source
pub fn split_env_string(env: &str) -> Option<(String, String)>
Expand description

Direct port of static int split_env_string(char *env, char **name, char **value) from Src/params.c:763.

Walks env until either = or end. Returns None (C 0) if:

  • any byte before = has the high bit set (c:771-777 — names outside the portable character set are silently rejected),
  • no = is present (c:783-785 fall-through),
  • or the name is empty (*str == '=' && str == tenv, c:782). Otherwise returns Some((name, value)) (C 1 + out-params).

Out-param style differs from C (we return a tuple); the rejection rules are 1:1.