Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions openstack_cli/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,10 @@ where
U: std::str::FromStr,
U::Err: Error + Send + Sync + 'static,
{
let pos = s
.find('=')
let (k, v) = s
.split_once('=')
.ok_or_else(|| format!("invalid KEY=value: no `=` found in `{s}`"))?;
Ok((s[..pos].parse()?, s[pos + 1..].parse()?))
Ok((k.parse()?, v.parse()?))
}

/// Parse a single key-value pair where value can be null
Expand All @@ -331,14 +331,14 @@ where
U: std::str::FromStr,
U::Err: Error + Send + Sync + 'static,
{
let pos = s
.find('=')
let (k, v) = s
.split_once('=')
.ok_or_else(|| format!("invalid KEY=value: no `=` found in `{s}`"))?;
if pos < s.len() - 1 {
Ok((s[..pos].parse()?, Some(s[pos + 1..].parse()?)))
} else {
Ok((s[..pos].parse()?, None))
}

let key = k.parse()?;
let val = (!v.is_empty()).then(|| v.parse()).transpose()?;

Ok((key, val))
}

pub(crate) fn parse_json(s: &str) -> Result<Value, Box<dyn Error + Send + Sync + 'static>>
Expand Down
Loading