True for strings that look like an intentional `key=value` key (e.g. `limit`, `safeSearch`, `second_arg`) rather than a positional value that merely contains a literal `=`, like a URL query string (`https://x.com?q=rust`).
(k: &str)
| 484 | /// `safeSearch`, `second_arg`) rather than a positional value that merely |
| 485 | /// contains a literal `=`, like a URL query string (`https://x.com?q=rust`). |
| 486 | fn looks_like_arg_key(k: &str) -> bool { |
| 487 | let mut chars = k.chars(); |
| 488 | matches!(chars.next(), Some(c) if c.is_ascii_alphabetic() || c == '_') |
| 489 | && chars.all(|c| c.is_ascii_alphanumeric() || c == '_') |
| 490 | } |
| 491 | |
| 492 | /// Split a `key=value` argument, trim both sides, and parse the value into |
| 493 | /// JSON. Shared by the `named_args` and `raw_args` loops in [`parse_args`]. |