Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plans for const generics? #310

Open
Progdrasil opened this issue Jan 18, 2021 · 2 comments
Open

Plans for const generics? #310

Progdrasil opened this issue Jan 18, 2021 · 2 comments

Comments

@Progdrasil
Copy link

I've been loving this crate so far. Seeing as min_const_generics is on track for rust 1.51, is there plans for using const generics within this crate? I find that being able to constrain the scale directly in my struct definitions would be a great use-case.

@paupino
Copy link
Owner

paupino commented Jan 20, 2021

While I haven't got any surefire plans to add min_const_generics just yet, I do plan to investigate where I can leverage the feature once it's released. Happy for suggestions if you have a specific area you'd like to target?

So you know, I've been doing the same with const_fn: I've been adding it where it makes sense, but also trying to be smart about where it gets added. At some stage I'd love to do a full library review to see where else I can make improvements, though admittedly am waiting until after I cover some of the add/mul improvements I have lined up.

@Progdrasil
Copy link
Author

Progdrasil commented Jan 20, 2021

Personally I'd love to do like in postgres where you set the precision and the scale statically

CREATE TABLE some_table (
    my_data_point   DECIMAL(11, 8) NOT NULL
);

And to be able to do this equivalent in my structs

struct SomeTable {
    my_data_point: Decimal<11, 8>,
}

Where the 8 would represent the scale used when creating a new Decimal. How ever im not really sure where the precision would fit inside the implementation. In which case even just setting the scale can be nice

struct SomeTable {
    my_data_point: Decimal<8>
}

Of course this would break the current API. So maybe something more along the lines of DecimalScale<const N: u32> or to opt into it with a feature flag or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants