Skip to main content

strip_reference

Function strip_reference 

Source
pub fn strip_reference(edited: &str) -> Option<&str>
Expand description

The reply half of an edited buffer, or None when the marker is gone.

None must be refused, never guessed at. The caller knows whether it appended a reference; if it did and the marker did not come back, there is no way to tell where the reply ends, and the two available guesses are “send the whole file” and “send some prefix of it”. The first mails a stranger their own message back together with whatever instructions were hidden in it; the second silently truncates a letter. The cost of refusing is that the user edits again, which is the cheap side of a decision whose expensive side is outbound.

The marker is matched anywhere in the file rather than at a fixed offset: editors reflow, and an editor that wrapped the comment block must not cost somebody their draft.