cathei / LinqGen

Alloc-free and fast replacement for Linq, with code generation
MIT License
287 stars 12 forks source link

Max and MaxBy return int instead of the container's type #9

Closed CyberBotX closed 1 year ago

CyberBotX commented 1 year ago

I was looking into LinqGen to see if it would be able to replace most of my vanilla LINQ usage, and stumbled upon this. Vanilla LINQ's Max and MaxBy methods will return the type of the container. LinqGen's returns int instead. (Min and MinBy are also affected.)

Example:

var list = new List<double> { 1.0, 2.0, 4.0 };

// Vanilla LINQ:
double maxVanilla = list.Max();
double maxNegVanilla = list.MaxBy(x => -x);

// LinqGen:
double maxGen = list.Gen().Max(); // This won't compile, as Max return int
double maxNegGen = list.Gen().MaxBy(x => -x); // This won't compile, as MaxBy returns int
cathei commented 1 year ago

Thank you for reporting this. It is fixed in v0.2.5.

Also thank you for trying this project out, please reach out if you encounter other issue!