rust-num / num-traits

Numeric traits for generic mathematics in Rust
Apache License 2.0
731 stars 135 forks source link

Exclusively increasing? #253

Open cheako opened 2 years ago

cheako commented 2 years ago

Hello, I was looking for a type that could only ever increase. Useful for the CPU side of Vulkan's Timeline Semaphores. I know I could trivially implement this, I was just wondering if this is something one of the num crates would be interested in including?

cuviper commented 2 years ago

It doesn't sound like a trait, at least, until there are multiple types with this characteristic and a need to be generic over those types. Then if a 3rd party crate is defining such types, it probably makes sense to define its own trait too.

My sense is that your idea would be quite domain specific, especially when getting into details like thread-safety and overflow behavior, so it doesn't seem like something that I would put in a generic num crate.

cheako commented 2 years ago

By the sound of this, we are on the same page WRGT the type and traits and how they would function. I did understand that num-traits wasn't the exact crate these would belong. Is there a number utility crate where this might live, where might I seek this addition? Creation of a new crate?

I'm guessing there are less than a handful of implementations for this and even though my domain would only use one, implementing all of them wouldn't seem a waste at all.

cuviper commented 2 years ago

I don't think there's a natural place for this, at least not in the crates in this org. Maybe you'd like to publish your own crate for it?