Skip to main content

blank_lifetimes

Function blank_lifetimes 

Source
pub fn blank_lifetimes(s: &str) -> String
Expand description

Replaces the apostrophe that opens a Rust lifetime with a space.

Rust and TypeScript disagree about '. In TypeScript it always quotes a string, which is what everything above assumes. In Rust it does too — a char literal — but it also introduces a lifetime, and a scanner that reads &'static str as an opening quote then skips everything up to the next apostrophe in the file, closing braces included. That is not hypothetical: it swallowed the end of a payload struct, the struct scanned as declaring no fields at all, and drift-check reported four fields as missing from a struct that has them. A scanner that invents drift is on its way to being ignored, which is the outcome this crate exists to prevent.

So the Rust scanner blanks lifetimes before reading anything, and the shared functions keep their one simple rule. Blanking is length-preserving, so every byte offset stays valid, and char literals ('a', '}') are left alone because those really are strings and must go on being skipped. TypeScript never comes through here: it has no lifetimes, and its single-quoted strings must keep working.