Skip to content

Commit a177f63

Browse files
authored
Implment additional unsigned integer From for partiql_value::Value (#449)
* Add additional From for Value Adds the following: 1. Value::from(u8) 2. Value::from(u16) 3. Value::from(u32) 4. Value::from(u64) 5. Value::from(u128)
1 parent 4d9ae54 commit a177f63

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99
### Changed
1010
- Adds quotes to the attributes of PartiQL tuple's debug output so it can be read and transformed using Kotlin `partiql-cli`
11+
- Adds u8, u16, u32, u64, and u128 support to partiql_value::Value::from(type)
1112
- [breaking] Changes the interface to `EvalPlan` to accept an `EvalContext`
1213

1314
### Added

partiql-value/src/lib.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,34 @@ impl From<u8> for Value {
11121112
}
11131113
}
11141114

1115+
impl From<u16> for Value {
1116+
#[inline]
1117+
fn from(n: u16) -> Self {
1118+
(n as usize).into()
1119+
}
1120+
}
1121+
1122+
impl From<u32> for Value {
1123+
#[inline]
1124+
fn from(n: u32) -> Self {
1125+
(n as usize).into()
1126+
}
1127+
}
1128+
1129+
impl From<u64> for Value {
1130+
#[inline]
1131+
fn from(n: u64) -> Self {
1132+
(n as usize).into()
1133+
}
1134+
}
1135+
1136+
impl From<u128> for Value {
1137+
#[inline]
1138+
fn from(n: u128) -> Self {
1139+
(n as usize).into()
1140+
}
1141+
}
1142+
11151143
impl From<f64> for Value {
11161144
#[inline]
11171145
fn from(f: f64) -> Self {
@@ -1276,7 +1304,12 @@ mod tests {
12761304
Value::from(f64::NEG_INFINITY),
12771305
Value::from(-123.456),
12781306
Value::Decimal(Box::new(dec!(1.23456))),
1307+
Value::from(138u8),
1308+
Value::from(1348u16),
1309+
Value::from(13849u32),
12791310
Value::from(123456),
1311+
Value::from(1384449u64),
1312+
Value::from(138444339u128),
12801313
Value::from(f64::INFINITY),
12811314
Value::from(""),
12821315
Value::from("abc"),

0 commit comments

Comments
 (0)