Skip to content

Commit f1b81d8

Browse files
committed
Move Default trait to where it's needed
1 parent d2c39ef commit f1b81d8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

crates/duckdb/src/r2d2.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl DuckdbConnectionManager {
9292
#[cfg(feature = "vscalar")]
9393
pub fn register_scalar_function<S: VScalar>(&self, name: &str) -> Result<()>
9494
where
95-
S::State: Debug,
95+
S::State: Debug + Default,
9696
{
9797
let conn = self.connection.lock().unwrap();
9898
conn.register_scalar_function::<S>(name)

crates/duckdb/src/vscalar/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub use arrow::{ArrowFunctionSignature, ArrowScalarParams, VArrowScalar};
2525
pub trait VScalar: Sized {
2626
/// State that persists across invocations of the scalar function (the lifetime of the connection)
2727
/// The state can be accessed by multiple threads, so it must be `Send + Sync`.
28-
type State: Default + Sized + Send + Sync;
28+
type State: Sized + Send + Sync;
2929
/// The actual function
3030
///
3131
/// # Safety
@@ -134,7 +134,10 @@ where
134134
impl Connection {
135135
/// Register the given ScalarFunction with default state
136136
#[inline]
137-
pub fn register_scalar_function<S: VScalar>(&self, name: &str) -> crate::Result<()> {
137+
pub fn register_scalar_function<S: VScalar>(&self, name: &str) -> crate::Result<()>
138+
where
139+
S::State: Default,
140+
{
138141
let set = ScalarFunctionSet::new(name);
139142
for signature in S::signatures() {
140143
let scalar_function = ScalarFunction::new(name)?;

0 commit comments

Comments
 (0)