-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release fix of custom merge fn for non-Copy types
Closes #32
- Loading branch information
Showing
16 changed files
with
68 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "configure_me_codegen" | ||
version = "0.3.10" | ||
version = "0.3.11" | ||
authors = ["Martin Habovštiak <[email protected]>"] | ||
description = "A library for processing application configuration easily." | ||
homepage = "https://github.com/Kixunil/configure_me" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bar = "Hello" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
configure_me_codegen/tests/expected_outputs/with_custom_merge/arg_parse_error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
FieldFoo(<u32 as ::configure_me::parse_arg::ParseArg>::Error), | ||
FieldBar(<String as ::configure_me::parse_arg::ParseArg>::Error), |
1 change: 1 addition & 0 deletions
1
configure_me_codegen/tests/expected_outputs/with_custom_merge/config.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub foo: Option<u32>, | ||
pub bar: Option<String>, |
7 changes: 6 additions & 1 deletion
7
configure_me_codegen/tests/expected_outputs/with_custom_merge/display_arg_parse_error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
ArgParseError::HelpRequested(program_name) => write!(f, "Usage: {} [--foo FOO]", program_name), | ||
ArgParseError::HelpRequested(program_name) => write!(f, "Usage: {} [--foo FOO] [--bar BAR]", program_name), | ||
ArgParseError::FieldFoo(err) => { | ||
write!(f, "Failed to parse argument '--foo': {}.\n\nHint: the value must be ", err)?; | ||
<u32 as ::configure_me::parse_arg::ParseArg>::describe_type(&mut *f)?; | ||
write!(f, ".") | ||
}, | ||
ArgParseError::FieldBar(err) => { | ||
write!(f, "Failed to parse argument '--bar': {}.\n\nHint: the value must be ", err)?; | ||
<String as ::configure_me::parse_arg::ParseArg>::describe_type(&mut *f)?; | ||
write!(f, ".") | ||
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
configure_me_codegen/tests/expected_outputs/with_custom_merge/env_parse_error.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
FieldFoo(<u32 as ::configure_me::parse_arg::ParseArg>::Error), | ||
FieldBar(<String as ::configure_me::parse_arg::ParseArg>::Error), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 13 additions & 5 deletions
18
configure_me_codegen/tests/expected_outputs/with_custom_merge/merge_in.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
match (&mut self.foo, other.foo) { | ||
(None, None) => (), | ||
(None, Some(val)) => self.foo = Some(val), | ||
(Some(_), None) => (), | ||
(Some(val0), Some(val1)) => (|a: &mut u32, b: u32| *a += b)(val0, val1), | ||
if let Some(foo) = other.foo { | ||
if let Some(foo_old) = &mut self.foo { | ||
(|a: &mut u32, b: u32| *a += b)(foo_old, foo); | ||
} else { | ||
self.foo = Some(foo); | ||
} | ||
} | ||
if let Some(bar) = other.bar { | ||
if let Some(bar_old) = &mut self.bar { | ||
(|a: &mut String, b: String| a.push_str(&b))(bar_old, bar); | ||
} else { | ||
self.bar = Some(bar); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
configure_me_codegen/tests/expected_outputs/with_custom_merge/raw_config.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
foo: Option<u32>, | ||
bar: Option<String>, |
2 changes: 2 additions & 0 deletions
2
configure_me_codegen/tests/expected_outputs/with_custom_merge/validate.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
let foo = self.foo; | ||
let bar = self.bar; | ||
|
||
Ok(super::Config { | ||
foo: foo.map(Into::into), | ||
bar: bar.map(Into::into), | ||
}) |