Say there is a collection trait that has an associated type for its items: trait CollectionItem { // ... } trait Collection { type Item: Col ...
Say there is a collection trait that has an associated type for its items: trait CollectionItem { // ... } trait Collection { type Item: Col ...
I know that generally you can't have something like Vec<dyn Iterator>> because of course you need to specify the associated type. Now, I can ...
I am trying to create a protocol R with an array of objects n which can be, in principle, different classes (N1, N2) but all subjects of the same prot ...
In case of argument in changeAccountConfirmDialog, how shall I implement the functionality for this variable. the error I am getting is "Member 'ch ...
I have the protocol like this I have the concrete struct like these. TitleTypeView and ButtonTypeView have the same super class. I have to combi ...
I'm trying to create a reusable protocol here. I'm getting errors which are added as comments here. Can't find any solution online to solve this. Ho ...
What is the difference in defining the associated types in a protocol directly that it inherits from another protocol vs using generic type constraint ...
I have a protocol with associated type. I want the protocol to impose some method only if the associated type conforms to Equatable. Something like t ...
Im trying to write boiler plate code for an MVVM architecture and I'm trying to make the View interface inside my ViewModel instead of binding propert ...
Goal When creating a networking layer for my apps, I typically use a generic method to fetch data from the server, e.g. I find this to be very ele ...
I'm trying to make my SwiftUI views more "Previewable" therefore I'm making them generic over their Store (ViewModel) so I can more easily mock them. ...
I would like to use SendMessageUseCase as a variable type, for example var sendMessageUseCase: SendMessageUseCase but I can't. I keep getting the err ...
How do I implement IntoIterator with a generic type parameter without getting into this kind of error, I think is the same error than here but the sol ...
I want to create an interface for a (numeric) algorithm for which I want to provide an implementation with ndarray and similar libraries (let's say py ...
I can define an associated function foo for an array like this: But how do I now call this function? I noticed that syntax like [usize;2]::foo() is ...
I have two traits Foo and Bar: In reality, I'll have many different types of Foos and Bars but each Foo has the associated trait for a type of Bar. ...
I did something like this: And I need to make it like that: I tried to do this, but it didn't work :c ...
Coming from a java/kotlin background I am trying to get my head around swift protocols with associated types. Why does the following snippet fail to c ...
I am currently trying to implement a structure of arrays. I want to implement the IntoIterator for the SOA in a way that yields the base structure on ...
I want to define a variable v1 of type protocol p1 in some other protocol p3 , and in class c1 which conform to protocol p3 i want to define v1 from a ...