Skip to content

Commit

Permalink
fix table_util.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed May 31, 2024
1 parent 0bc8522 commit b9ca4a3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/utils/table_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ macro_rules! make_table_field_map_btree {
($vec_ref:expr,$($field_name:ident$(.)?)+) => {{
let mut ids = std::collections::BTreeMap::new();
for item in $vec_ref {
match &item $(.$field_name)+ {
std::option::Option::Some(ref v) => {
match item.$($field_name.)+as_ref() {
std::option::Option::Some(v) => {
ids.insert(v.clone(), item.clone());
}
_ => {}
Expand All @@ -260,11 +260,10 @@ macro_rules! make_table_field_map_btree {
#[macro_export]
macro_rules! make_table_field_map {
($vec_ref:expr,$($field_name:ident$(.)?)+) => {{
let vec = $vec_ref;
let mut ids = std::collections::HashMap::with_capacity(vec.len());
for item in vec {
match item $(.$field_name)+ {
std::option::Option::Some(ref v) => {
let mut ids = std::collections::HashMap::with_capacity($vec_ref.len());
for item in $vec_ref {
match item.$($field_name.)+as_ref() {
std::option::Option::Some(v) => {
ids.insert(v.clone(), item.clone());
}
_ => {}
Expand All @@ -281,7 +280,7 @@ macro_rules! make_table_field_vec {
($vec_ref:expr,$($field_name:ident$(.)?)+) => {{
let mut ids = std::vec::Vec::with_capacity($vec_ref.len());
for item in $vec_ref {
match &item $(.$field_name)+ {
match item.$($field_name.)+as_ref() {
std::option::Option::Some(v) => {
ids.push(v.clone());
}
Expand Down

0 comments on commit b9ca4a3

Please sign in to comment.