Skip to content

Commit

Permalink
Merge #640
Browse files Browse the repository at this point in the history
640: fix #638 r=jstarry a=astraw

This fixes #638.

So far, I was not able to the test suite to run, so I wasn't able to write a test for this.

Co-authored-by: Andrew Straw <strawman@astraw.com>
Co-authored-by: Justin Starry <jstarry@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 22, 2019
2 parents 24d39f9 + f8d0723 commit 6a05e51
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
4 changes: 3 additions & 1 deletion crates/macro/src/derive_props/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ impl ToTokens for PropsBuilder<'_> {
#(impl #step_trait for #step_names {})*

#[doc(hidden)]
#vis struct #builder_name#step_generics {
#vis struct #builder_name#step_generics
#where_clause
{
wrapped: ::std::boxed::Box<#wrapper_name#ty_generics>,
_marker: ::std::marker::PhantomData<#step_generic_param>,
}
Expand Down
4 changes: 3 additions & 1 deletion crates/macro/src/derive_props/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ impl ToTokens for PropsWrapper<'_> {
let wrapper_default_setters = self.default_setters();

let wrapper = quote! {
struct #wrapper_name#generics {
struct #wrapper_name#generics
#where_clause
{
#(#wrapper_field_defs)*
}

Expand Down
18 changes: 18 additions & 0 deletions tests/derive_props/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,22 @@ mod t5 {
}
}

mod t6 {
use super::*;
use std::str::FromStr;

#[derive(Properties, Clone)]
pub struct Props<T: FromStr + Clone>
where
<T as FromStr>::Err: Clone,
{
#[props(required)]
value: Result<T, <T as FromStr>::Err>,
}

fn required_prop_generics_with_where_clause_should_work() {
Props::<String>::builder().value(Ok(String::from(""))).build();
}
}

fn main() {}

0 comments on commit 6a05e51

Please sign in to comment.