HaoYang670 opened a new issue, #2001:
URL: https://github.com/apache/arrow-rs/issues/2001
**Is your feature request related to a problem or challenge? Please describe
what you are trying to do.**
This is actually a question or a discussion.
Our current may to implement `Decimal128` and `Decimal256` is that:
```rust
trait BasicDecimal: ... {
const BIT_LENGTH: i32;
}
struct Decimal128 {}
struct Decimal256 {}
impl BasicDecimal for Decimal128 {}
impl BasicDecimal for Decimla256{}
impl Decimal128 {}
```
Actually I find an alternative way to implement this.
```rust
struct Decimal<const BYTE_LENGTH: usize> {
precision: usize,
scale: usize,
value: [u8; BYTE_LENGTH],
}
impl<BYTE_LENGTH> Decimal<BYTE_LENGTH> {}
type Decimal128 = Decimal<16>;
type Decimal256 = Decimal<32>;
impl Decimal128 {}
```
I am not sure which one is better, but these are some pros and cons I
thought:
pros: don't need the basic trait, reducing using macro when coding (better
debugging)
cons: cannot restrict the bit_length to be 128 or 258 because
`const_generic_exprs` is an unstable feature.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]