Skip to main content

escape_rust_string

Function escape_rust_string 

Source
pub fn escape_rust_string(sql: &str) -> String
Expand description

Escape SQL text for splicing into a Rust plain "..." string literal.

Rust string literals permit raw newlines, so only backslash and " need escaping. Used by rust-sibyl and rust-sqlx (the latter’s sqlx::query!/query_as! macros receive the decoded string value at compile time, identical to the unescaped source text, so escaping here has no effect on the macro’s compile-time query verification).