Removing unwrap
textsender_models PR / Rustfmt (pull_request) Successful in 58s
textsender_models PR / Check (pull_request) Successful in 1m16s
textsender_models PR / Clippy (pull_request) Successful in 1m21s
Release Tagging / release (pull_request) Successful in 36s

This commit is contained in:
2026-07-02 12:36:49 -04:00
parent 0749e6419f
commit 2a8742cc4a
+17 -4
View File
@@ -2,11 +2,19 @@
/// extract it into some strings /// extract it into some strings
pub fn delimitize(var: &crate::envy::EnvVar) -> Result<Vec<String>, std::io::Error> { pub fn delimitize(var: &crate::envy::EnvVar) -> Result<Vec<String>, std::io::Error> {
if var.has_delimiter { if var.has_delimiter {
Ok(var let values: Vec<String> = match var
.value .value
.split(var.delimiter) .split(var.delimiter)
.map(|c| c.parse::<String>().unwrap()) .map(|c| c.parse::<String>())
.collect()) .collect()
{
Ok(v) => v,
Err(err) => {
return Err(std::io::Error::other(err));
}
};
Ok(values)
} else { } else {
Err(std::io::Error::other( Err(std::io::Error::other(
"Environment variable does not have a delimiter", "Environment variable does not have a delimiter",
@@ -26,7 +34,12 @@ mod tests {
has_delimiter: true, has_delimiter: true,
delimiter: '|', delimiter: '|',
}; };
let all_values = vec!["Atlantic".to_string(), "Pacific".to_string(), "Indian".to_string(), "Arctic".to_string()]; let all_values = vec![
"Atlantic".to_string(),
"Pacific".to_string(),
"Indian".to_string(),
"Arctic".to_string(),
];
match delimitize(&envvar) { match delimitize(&envvar) {
Ok(values) => { Ok(values) => {