Skip to content

Commit

Permalink
add impl TryFrom<Scalar> for $T
Browse files Browse the repository at this point in the history
  • Loading branch information
a10y committed Jun 5, 2024
1 parent c527cb5 commit 89ec624
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 0 additions & 8 deletions vortex-datetime-parts/src/compute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,10 @@ mod test {
let local = decode_to_localdatetime(&date_times.into_array()).unwrap();

let elem0: i64 = scalar_at(&local.timestamps(), 0)
.unwrap()
.value()
.as_pvalue()
.unwrap()
.unwrap()
.try_into()
.unwrap();
let elem1: i64 = scalar_at(&local.timestamps(), 1)
.unwrap()
.value()
.as_pvalue()
.unwrap()
.unwrap()
.try_into()
.unwrap();
Expand Down
8 changes: 8 additions & 0 deletions vortex-scalar/src/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ macro_rules! primitive_scalar {
.ok_or_else(|| vortex_err!("Can't extract present value from null scalar"))
}
}

impl TryFrom<Scalar> for $T {
type Error = VortexError;

fn try_from(value: Scalar) -> Result<Self, Self::Error> {
<$T>::try_from(&value)
}
}
};
}

Expand Down

0 comments on commit 89ec624

Please sign in to comment.