summaryrefslogtreecommitdiffstats
path: root/src/commands/env_of.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-03-18 08:57:02 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-03-18 08:59:31 +0100
commit9870dd0967f33d9f8bf0279eaa03294da0b55148 (patch)
treefac285d2dd8b5116ead70e5c33bbe3d75e433b09 /src/commands/env_of.rs
parent13a85ddc5768a25f985eeb7b7dd1a8de5dce87d6 (diff)
Rewrite PackageVersionConstraint constructing
Use the TryFrom trait rather than a `::new()` constructor that can fail. This is way more idomatic. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/commands/env_of.rs')
-rw-r--r--src/commands/env_of.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/commands/env_of.rs b/src/commands/env_of.rs
index 4ee48d1..c763a23 100644
--- a/src/commands/env_of.rs
+++ b/src/commands/env_of.rs
@@ -8,6 +8,8 @@
// SPDX-License-Identifier: EPL-2.0
//
+use std::convert::TryFrom;
+
use anyhow::Result;
use clap::ArgMatches;
use log::trace;
@@ -29,8 +31,7 @@ pub async fn env_of(matches: &ArgMatches, repo: Repository) -> Result<()> {
.unwrap();
let constraint = matches
.value_of("package_version_constraint")
- .map(String::from)
- .map(PackageVersionConstraint::new)
+ .map(PackageVersionConstraint::try_from)
.unwrap()?;
trace!(
"Checking for package with name = {} and version = {:?}",