Skip emitting a transposed type if the original type is entirely generic (#4838)
* Skip transposed type if the type is generic * fix clippy
This commit is contained in:
1 parent
e4297d0e09
commit
9b52aa6607
2 files changed
+192
-31
No files matched your search
@@ -138,6 +138,20 @@ mod macro_tests {
|
||||
store.check();
|
||||
}
|
||||
|
||||
fn derive_generic_struct_transposed_passthrough() {
|
||||
#[derive(Store)]
|
||||
struct Item<const COUNT: usize, T> {
|
||||
contents: T,
|
||||
}
|
||||
|
||||
let mut store = use_store(|| Item::<0, _> {
|
||||
contents: "Learn about stores".to_string(),
|
||||
});
|
||||
|
||||
let Item { contents } = store.transpose();
|
||||
let contents: String = contents();
|
||||
}
|
||||
|
||||
fn derive_tuple() {
|
||||
#[derive(Store, PartialEq, Clone, Debug)]
|
||||
struct Item(bool, String);
|
||||
@@ -342,4 +356,28 @@ mod macro_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn derive_generic_enum_transpose_passthrough() {
|
||||
#[derive(Store, PartialEq, Clone, Debug)]
|
||||
#[non_exhaustive]
|
||||
enum Enum<const COUNT: usize, T> {
|
||||
Foo,
|
||||
Bar(T),
|
||||
BarFoo { foo: T },
|
||||
}
|
||||
|
||||
let mut store = use_store(|| Enum::<0, _>::Bar("Hello".to_string()));
|
||||
|
||||
let transposed = store.transpose();
|
||||
use Enum::*;
|
||||
match transposed {
|
||||
Enum::Foo => {}
|
||||
Bar(bar) => {
|
||||
let bar: String = bar();
|
||||
}
|
||||
BarFoo { foo } => {
|
||||
let foo: String = foo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user