Skip to main content

canonicalize_code

Function canonicalize_code 

Source
pub fn canonicalize_code(code: &str) -> String
Expand description

Canonicalize code for consistent hashing.

This normalizes whitespace to ensure semantically identical code produces the same hash, regardless of:

  • Leading/trailing whitespace or newlines on the whole string
  • Trailing whitespace on individual lines
  • Windows vs Unix line endings (\r\n vs \n)
  • Blank lines between statements