Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit bb072fe

Browse files
committed
main: allow fallible conversions during CLI parsing
1 parent d66f476 commit bb072fe

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

src/combiner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Combiner {
121121
.rel_manifest_dir(self.rel_manifest_dir)
122122
.success_message(self.success_message)
123123
.legacy_manifest_dirs(self.legacy_manifest_dirs)
124-
.output_script(path_to_str(&output_script)?);
124+
.output_script(path_to_str(&output_script)?.into());
125125
scripter.run()?;
126126

127127
// Make the tarballs.
@@ -131,7 +131,7 @@ impl Combiner {
131131
tarballer
132132
.work_dir(self.work_dir)
133133
.input(self.package_name)
134-
.output(path_to_str(&output)?);
134+
.output(path_to_str(&output)?.into());
135135
tarballer.run()?;
136136

137137
Ok(())

src/generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl Generator {
8585
.rel_manifest_dir(self.rel_manifest_dir)
8686
.success_message(self.success_message)
8787
.legacy_manifest_dirs(self.legacy_manifest_dirs)
88-
.output_script(path_to_str(&output_script)?);
88+
.output_script(path_to_str(&output_script)?.into());
8989
scripter.run()?;
9090

9191
// Make the tarballs
@@ -95,7 +95,7 @@ impl Generator {
9595
tarballer
9696
.work_dir(self.work_dir)
9797
.input(self.package_name)
98-
.output(path_to_str(&output)?);
98+
.output(path_to_str(&output)?.into());
9999
tarballer.run()?;
100100

101101
Ok(())

src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use anyhow::{Context, Result};
22
use clap::{App, ArgMatches};
3+
use std::convert::TryInto;
34

45
fn main() -> Result<()> {
56
let yaml = clap::load_yaml!("main.yml");
@@ -19,7 +20,11 @@ macro_rules! parse(
1920
($matches:expr => $type:ty { $( $option:tt => $setter:ident, )* }) => {
2021
{
2122
let mut command: $type = Default::default();
22-
$( $matches.value_of($option).map(|s| command.$setter(s)); )*
23+
$(
24+
if let Some(val) = $matches.value_of($option) {
25+
command.$setter(val.try_into()?);
26+
}
27+
)*
2328
command
2429
}
2530
}

src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ macro_rules! actor {
142142

143143
impl $name {
144144
$( $( #[ $field_attr ] )+
145-
pub fn $field<T: Into<$type>>(&mut self, value: T) -> &mut Self {
146-
self.$field = value.into();
145+
pub fn $field(&mut self, value: $type) -> &mut Self {
146+
self.$field = value;
147147
self
148148
})+
149149
}

0 commit comments

Comments
 (0)