Skip to main content

normalize_string

Function normalize_string 

Source
pub fn normalize_string(text: &str) -> String
Expand description

Rewrite a string literal to use the quote style that needs fewer escapes.

The guide prefers double quotes, allows single quotes when they avoid escapes, and prefers double quotes on a tie. Applies to plain strings and to the & and ^ prefixed StringName and NodePath forms, whose quoted part follows the same rules.

Raw and triple-quoted strings are returned unchanged: in a raw string the backslash is not reliably an escape, and a triple-quoted string may contain bare quotes whose meaning depends on position.