Skip to main content

zig_ident

Function zig_ident 

Source
pub fn zig_ident(name: &str) -> String
Expand description

Convenience: always returns a usable Zig identifier.

Sanitizes the input so that it is a valid Zig identifier:

  1. Non-[A-Za-z0-9_] characters are replaced with _ (so serde renames like og:image or Content-Type become og_image / Content_Type).
  2. A leading digit is prefixed with _.
  3. The result is then checked against Zig’s reserved-word list and escaped with a trailing _ if necessary.