Skip to main content

split_at_where

Function split_at_where 

Source
pub fn split_at_where(text: &str) -> (String, Option<String>)
Expand description

Split a comprehension text on the top-level where keyword. Returns (clause_text, Some(predicate)) if a where clause is present at paren-depth 0, or (text, None) otherwise. The predicate is trimmed; the where keyword itself is consumed.

“Top-level” means paren-depth 0 — where substrings inside (...), [...], or {...} are ignored, so a clause expression like f(where_clause('foo')) survives intact.