From 0ee6f18be0f08650eb6c45797cc8245591148c3e Mon Sep 17 00:00:00 2001 From: Edgar Date: Mon, 4 Mar 2024 14:04:46 -0800 Subject: [PATCH] comment --- src/types/from_sql.rs | 57 ++----------------------------------------- 1 file changed, 2 insertions(+), 55 deletions(-) diff --git a/src/types/from_sql.rs b/src/types/from_sql.rs index 6eb9aef..a327482 100644 --- a/src/types/from_sql.rs +++ b/src/types/from_sql.rs @@ -175,61 +175,8 @@ impl<'a> FromSql<'a> for uuid::Uuid { } } -// macro_rules! from_sql_vec_impl { -// ( $( $t:ty: $k:pat => $f:expr ),* ) => { -// $( -// impl<'a> FromSql<'a> for Vec<$t> { -// fn from_sql(value: ValueRef<'a>) -> FromSqlResult { -// match value { -// ValueRef::Array($k, vs) => { -// let f: fn(ValueRef<'a>) -> FromSqlResult<$t> = $f; -// let mut result = Vec::with_capacity(vs.len()); -// for r in vs.iter() { -// let value: $t = f(r.clone())?; -// result.push(value); -// } -// Ok(result) -// } -// _ => { -// let from = SqlType::from(value.clone()).to_string(); -// Err(Error::FromSql(FromSqlError::InvalidType { -// src: from, -// dst: format!("Vec<{}>", stringify!($t)).into(), -// })) -// } -// } -// } -// } -// )* -// // New implementation for nested Vec> -// $( -// impl<'a> FromSql<'a> for Vec> { -// fn from_sql(value: ValueRef<'a>) -> FromSqlResult { -// match value { -// ValueRef::Array(SqlType::Array(_), outer_vs) => { -// outer_vs.iter().map(|outer_v| match outer_v { -// ValueRef::Array($k, inner_vs) => { -// let f: fn(ValueRef<'a>) -> FromSqlResult<$t> = $f; -// inner_vs.iter().map(|inner_v| f(inner_v.clone())).collect() -// }, -// _ => Err(Error::FromSql(FromSqlError::InvalidType { -// src: SqlType::from(outer_v.clone()).to_string(), -// dst: format!("Vec>", stringify!($t)).into(), -// })), -// }).collect() -// }, -// _ => Err(Error::FromSql(FromSqlError::InvalidType { -// src: SqlType::from(value.clone()).to_string(), -// dst: "Vec>".into(), -// })), -// } -// } -// } -// )* - -// }; -// } macro_rules! from_sql_vec_impl { + // Base case: Vec ( $($t:ty: $k:pat => $f:expr),* ) => { @@ -256,7 +203,7 @@ macro_rules! from_sql_vec_impl { } } } - + // Recursive case: Vec> impl<'a> FromSql<'a> for Vec> { fn from_sql(value: ValueRef<'a>) -> FromSqlResult { match value {