git.delta.rocks / jrsonnet / refs/commits / 79e339a14c35

difftreelog

fix Allow = characters in tla-code

expelledboy2023-06-19parent: #777cdf5.patch.diff
in: master

1 file changed

modifiedcrates/jrsonnet-cli/src/stdlib.rsdiffbeforeafterboth
13impl FromStr for ExtStr {13impl FromStr for ExtStr {
14 type Err = &'static str;14 type Err = &'static str;
15 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {15 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
16 let out: Vec<_> = s.split('=').collect();
17 match out.len() {16 match s.find('=') {
18 1 => Ok(ExtStr {17 Some(idx) => Ok(ExtStr {
19 name: out[0].to_owned(),18 name: s[..idx].to_owned(),
20 value: std::env::var(out[0]).or(Err("missing env var"))?,19 value: s[idx + 1..].to_owned(),
21 }),20 }),
22 2 => Ok(ExtStr {21 None => Ok(ExtStr {
23 name: out[0].to_owned(),22 name: s.to_owned(),
24 value: out[1].to_owned(),23 value: std::env::var(s).or(Err("missing env var"))?,
25 }),24 }),
26
27 _ => Err("bad ext-str syntax"),
28 }25 }
29 }26 }
30}27}