pub fn variable_at_offset(text: &str, offset: usize) -> Option<&str>Expand description
Extract a variable name from $(VAR) or ${VAR} surrounding the given byte offset.
Returns None if the offset is not inside a variable reference.
ยงExample
use makefile_lossless::variable_at_offset;
assert_eq!(variable_at_offset("$(FOO)", 2), Some("FOO"));
assert_eq!(variable_at_offset("${BAR}", 3), Some("BAR"));
assert_eq!(variable_at_offset("plain text", 3), None);