Category "generics"

Function type cannot have type parameters

I am trying to write a sample program to try and implementing the a data structure using go generic proposed in go2. As part of this I want to define a iterator

How to use a generic session with Actix and Paperclip?

I've created a server using Actix Web which has authentication support. Now I want to add an OpenAPI Specification using paperclip. Normally you only have to ad

Is there an idiomatic way to have a generic over T, &T, Box<T>, Arc<T>, and so forth, where T implements some trait R?

Let's say you have a structure that you want to be a generic over time type T, so long as that type implements some trait R. That's pretty trivial: trait R {

Map Typescript generic array

Suppose I have an object with a static set of keys, and then a type specifying a subset of those keys as a static array: const myBigStaticObject = { key1: ()

How to convert String to Generics in java

I have a class similar to this: public class Car<T> { private T model; private CarBodyParts body; } public class CarBodyParts { private Integer

Generic function typedef in C - how to get rid of initialization warning?

I'm experimenting with generic-like code and I have a function like this (a lot of not relevant code removed): typedef uint8_t (*struct_converter_t)(void *, cha

Generic function typedef in C - how to get rid of initialization warning?

I'm experimenting with generic-like code and I have a function like this (a lot of not relevant code removed): typedef uint8_t (*struct_converter_t)(void *, cha

How to assign or return generic T that is constrained by union?

In other words, how do I implement type-specific solutions for different types in a union type set? Given the following code... type FieldType interface { s

Facing issue with having generic as return type in Golang

I'm invoking a function from another library whose return signature is defined as under: (*studentlib.Student[StudentResponse], error) Student is defined as: t

Python generic that adds typed functionality to extend existing types incorrectly typed

I am interested in creating a generic to add a fixed functionality to different types in python. I have a semi working solution, but it's tying is problematic.

is there a Generic way to assert type? [duplicate]

I have found myself writing the same function X number of times to get different types of Items out of my go-cache. The duplicate functions ar

var keyword gives an error in IntelliJ (Wildcards may be used only as reference parameters)

When I write this code in IntelliJ, it gives this error: Wildcards may be used only as reference parameters. Here is my code static <T extends Iterable<

Nestjs create Generic CRUD service

I want to create a base service using a generic class which I wrote below: import { BaseEntity } from './base.entity'; import { Repository } from 'typeorm'; e

Dart, Can't call Generic's method

I am trying to create an abstract data model where i pass data and type a and then is return list, but when i can't call T.fromJson() method, note that passes t

failed to produce diagnostic for expression, Xcode 11.4, Moya

After updating to Xcode 11.4, I started to get this error Failed to produce diagnostic for expression please file a bug report On: let provider = MoyaProvider

Java get generic type of static method at runtime

So I was reading through the source code of Collections.java, there is a generic method copy(). I simplified it to this: public static <T> void copy(List&

Unable to assign the result returned by the Method that receives a generic List and returns a List<?>

I'm trying to filter a List of objects that implements an interface. And I'm trying to create a generic method for all the classes. Something like: interface So

Avoiding generic class with many type parameters, when the consumer of those types are tightly coupled

I am trying to come up with a way to do this where I can have type safety but also loose coupling of a couple of different components in my class. I am running

Enforce providing <T> in Dart generic method

How can I enforce providing the generic type of a generic method in dart. By default, dart allows us to not provide a generic type at all. And this should be a

How to iterate over a union of slices passed in a generic function? (T has no core type)

I am testing out generics in go 1.18 and took a look at this example. I would like to recreate that example but instead be able to pass in a slice of int or sli