You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0277]: the trait bound `T:MyClass` is not satisfied
--> src/lib.rs:185:1
|
185 | #[implement(IClassFactory)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyClass` is not implemented for `T`, which is required by `MyClassFactory<T>:IClassFactory_Impl`
|
note: required for `MyClassFactory<T>` to implement `IClassFactory_Impl`
--> src/lib.rs:188:23
|
188 | impl<T:MyClass> IClassFactory_Impl for MyClassFactory<T> {
| ------- ^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^
| |
| unsatisfied trait bound introduced here
note: required by a bound in `IClassFactory_Vtbl::new`
--> /Users/roblabla/.cargo_isengard/registry/src/index.crates.io-6f17d22bba15001f/windows-0.52.0/src/Windows/Win32/System/Com/impl.rs:1191:81
|
1191 | pub const fn new<Identity:::windows_core::IUnknownImpl<Impl = Impl>,Impl:IClassFactory_Impl,constOFFSET:isize>() -> IClassFactory_Vtbl{
| ^^^^^^^^^^^^^^^^^^ required by this bound in `IClassFactory_Vtbl::new`
= note: this error originates in the attribute macro `implement` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider restricting type parameter `T`
|
186 | struct MyClassFactory<T:MyClassProvider>(PhantomData<T>);
| ++++++++++++++
Doing the suggested change (adding the bound on the struct) doesn't help:
IMO, if a generic bound is found on the struct that implements is on, it should use it for all the generated impl block.
My use-case is to provide a safe wrapper around a COM interface. I'm creating a trait that mirrors the COM interface's trait, but wrapping all the structures in safe wrappers, to hopefully make implementing it easier and safer.
The text was updated successfully, but these errors were encountered:
Keep in mind that the generic support provided by the implement macro is intended to handle WinRT generic interfaces, but I'm certainly happy to expand it to support generic programming in general so I welcome the improvement.
Suggestion
Currently, the
implement
macro does not support generic bounds. For instance, the following:Will fail to compile with the following error:
Doing the suggested change (adding the bound on the struct) doesn't help:
IMO, if a generic bound is found on the
struct
that implements is on, it should use it for all the generated impl block.My use-case is to provide a safe wrapper around a COM interface. I'm creating a trait that mirrors the COM interface's trait, but wrapping all the structures in safe wrappers, to hopefully make implementing it easier and safer.
The text was updated successfully, but these errors were encountered: