pub fn active(&'a self) -> impl Iterator<Item = ActiveColumnState> + 'a {
        let min_cols = self
            .renderer
            .metadata()
            .names
            .as_ref()
            .map_or(0, |x| x.len());

        let last_col = self.config.columns.last().and_then(|x| x.as_ref());
        let has_blank_tail = last_col.is_none()
            || self.config.columns.len() < self.named_columns.len()
            || self.config.columns.iter().filter(|x| x.is_some()).count()
                == self
                    .session
                    .metadata()
                    .get_table_columns()
                    .map(|x| x.len())
                    .unwrap_or_default()
                    + self.config.expressions.len();

        match &self.is_dragover_column {
            Some((to_index, from_column)) => {
                let is_to_swap = self.renderer.metadata().is_swap(*to_index);
                let to_column = self.config.columns.get(*to_index);
                let is_to_empty = to_column.map(|x| x.is_none()).unwrap_or_default();
                let from_index = self
                    .config
                    .columns
                    .iter()
                    .position(|x| x.as_ref() == Some(from_column));

                let is_from_required = from_index
                    .and_then(|x| self.renderer.metadata().min.map(|y| x < y))
                    .unwrap_or_default();

                let is_from_swap = from_index
                    .map(|x| self.renderer.metadata().is_swap(x))
                    .unwrap_or_default();

                let is_dragover_after_last = *to_index == self.config.columns.len();
                let is_dragover_last = is_dragover_after_last && from_index.is_none()
                    || (*to_index == self.config.columns.len() - 1 && from_index.is_some());

                let tail = if has_blank_tail || is_dragover_last {
                    [].iter().cloned()
                } else {
                    [Some(&None)].iter().cloned()
                };

                if is_dragover_after_last && from_index.is_some() {
                    self.to_active_column_state(Box::new(
                        self.config.columns.iter().map(Some).chain(tail),
                    ))
                } else if is_to_swap || is_from_required {
                    let all_columns = self.config.columns.iter().filter_map(move |x| match x {
                        Some(x) if x == from_column => {
                            if is_to_empty && !is_from_swap {
                                None
                            } else {
                                Some(to_column.unwrap_or(&None))
                            }
                        }
                        x => Some(x),
                    });

                    let before_cols = all_columns
                        .clone()
                        .pad_using(min_cols, |_| &None)
                        .take(*to_index)
                        .map(Some);

                    let after_cols = all_columns.skip(*to_index + 1).map(Some);
                    self.to_active_column_state(Box::new(
                        before_cols
                            .chain([None].iter().cloned())
                            .chain(after_cols)
                            .chain(tail),
                    ))
                } else {
                    let to_offset = match to_column {
                        Some(Some(_)) => *to_index,
                        _ => *to_index + 1,
                    };

                    let all_columns = self.config.columns.iter().filter_map(move |x| match x {
                        Some(x) if x == from_column => {
                            if !is_from_swap {
                                None
                            } else {
                                Some(&None)
                            }
                        }
                        x => Some(x),
                    });

                    let before_cols = all_columns
                        .clone()
                        .pad_using(min_cols, |_| &None)
                        .take(*to_index)
                        .map(Some);

                    let after_cols = all_columns.skip(to_offset).map(Some);
                    self.to_active_column_state(Box::new(
                        before_cols
                            .chain([None].iter().cloned())
                            .chain(after_cols)
                            .chain(tail),
                    ))
                }
            }
            _ => {
                let tail = if has_blank_tail {
                    [].iter().cloned()
                } else {
                    [Some(&None)].iter().cloned()
                };

                self.to_active_column_state(Box::new(
                    self.config.columns.iter().map(Some).chain(tail),
                ))
            }
        }
    }
/// Generate an iterator for active columns, which are represented as
/// `Option` for dragover and missing columns.
Generate an iterator for active columns, which are represented as
`Option` for dragover and missing columns.
Generate an iterator for active columns which are represented as ` Option ` for dragover and missing columns .
pub fn active(&'a self) -> impl Iterator<Item = ActiveColumnState> + 'a {
        let min_cols = self
            .renderer
            .metadata()
            .names
            .as_ref()
            .map_or(0, |x| x.len());
        let last_col = self.config.columns.last().and_then(|x| x.as_ref());
        let has_blank_tail = last_col.is_none()
            || self.config.columns.len() < self.named_columns.len()
            || self.config.columns.iter().filter(|x| x.is_some()).count()
                == self
                    .session
                    .metadata()
                    .get_table_columns()
                    .map(|x| x.len())
                    .unwrap_or_default()
                    + self.config.expressions.len();
        match &self.is_dragover_column {
            Some((to_index, from_column)) => {
                let is_to_swap = self.renderer.metadata().is_swap(*to_index);
                let to_column = self.config.columns.get(*to_index);
                let is_to_empty = to_column.map(|x| x.is_none()).unwrap_or_default();
                let from_index = self
                    .config
                    .columns
                    .iter()
                    .position(|x| x.as_ref() == Some(from_column));
                let is_from_required = from_index
                    .and_then(|x| self.renderer.metadata().min.map(|y| x < y))
                    .unwrap_or_default();
                let is_from_swap = from_index
                    .map(|x| self.renderer.metadata().is_swap(x))
                    .unwrap_or_default();
                let is_dragover_after_last = *to_index == self.config.columns.len();
                let is_dragover_last = is_dragover_after_last && from_index.is_none()
                    || (*to_index == self.config.columns.len() - 1 && from_index.is_some());
                let tail = if has_blank_tail || is_dragover_last {
                    [].iter().cloned()
                } else {
                    [Some(&None)].iter().cloned()
                };
                if is_dragover_after_last && from_index.is_some() {
                    self.to_active_column_state(Box::new(
                        self.config.columns.iter().map(Some).chain(tail),
                    ))
                } else if is_to_swap || is_from_required {
                    let all_columns = self.config.columns.iter().filter_map(move |x| match x {
                        Some(x) if x == from_column => {
                            if is_to_empty && !is_from_swap {
                                None
                            } else {
                                Some(to_column.unwrap_or(&None))
                            }
                        }
                        x => Some(x),
                    });
                    let before_cols = all_columns
                        .clone()
                        .pad_using(min_cols, |_| &None)
                        .take(*to_index)
                        .map(Some);
                    let after_cols = all_columns.skip(*to_index + 1).map(Some);
                    self.to_active_column_state(Box::new(
                        before_cols
                            .chain([None].iter().cloned())
                            .chain(after_cols)
                            .chain(tail),
                    ))
                } else {
                    let to_offset = match to_column {
                        Some(Some(_)) => *to_index,
                        _ => *to_index + 1,
                    };
                    let all_columns = self.config.columns.iter().filter_map(move |x| match x {
                        Some(x) if x == from_column => {
                            if !is_from_swap {
                                None
                            } else {
                                Some(&None)
                            }
                        }
                        x => Some(x),
                    });
                    let before_cols = all_columns
                        .clone()
                        .pad_using(min_cols, |_| &None)
                        .take(*to_index)
                        .map(Some);
                    let after_cols = all_columns.skip(to_offset).map(Some);
                    self.to_active_column_state(Box::new(
                        before_cols
                            .chain([None].iter().cloned())
                            .chain(after_cols)
                            .chain(tail),
                    ))
                }
            }
            _ => {
                let tail = if has_blank_tail {
                    [].iter().cloned()
                } else {
                    [Some(&None)].iter().cloned()
                };
                self.to_active_column_state(Box::new(
                    self.config.columns.iter().map(Some).chain(tail),
                ))
            }
        }
    }
pub fn active ( & ' a self ) -> impl Iterator < Item = ActiveColumnState > + ' a { let min_cols = self . renderer . metadata ( ) . names . as_ref ( ) . map_or ( 0 , | x | x . len ( ) ) ; let last_col = self . config . columns . last ( ) . and_then ( | x | x . as_ref ( ) ) ; let has_blank_tail = last_col . is_none ( ) || self . config . columns . len ( ) < self . named_columns . len ( ) || self . config . columns . iter ( ) . filter ( | x | x . is_some ( ) ) . count ( ) == self . session . metadata ( ) . get_table_columns ( ) . map ( | x | x . len ( ) ) . unwrap_or_default ( ) + self . config . expressions . len ( ) ; match & self . is_dragover_column { Some ( ( to_index , from_column ) ) => { let is_to_swap = self . renderer . metadata ( ) . is_swap ( * to_index ) ; let to_column = self . config . columns . get ( * to_index ) ; let is_to_empty = to_column . map ( | x | x . is_none ( ) ) . unwrap_or_default ( ) ; let from_index = self . config . columns . iter ( ) . position ( | x | x . as_ref ( ) == Some ( from_column ) ) ; let is_from_required = from_index . and_then ( | x | self . renderer . metadata ( ) . min . map ( | y | x < y ) ) . unwrap_or_default ( ) ; let is_from_swap = from_index . map ( | x | self . renderer . metadata ( ) . is_swap ( x ) ) . unwrap_or_default ( ) ; let is_dragover_after_last = * to_index == self . config . columns . len ( ) ; let is_dragover_last = is_dragover_after_last && from_index . is_none ( ) || ( * to_index == self . config . columns . len ( ) - 1 && from_index . is_some ( ) ) ; let tail = if has_blank_tail || is_dragover_last { [ ] . iter ( ) . cloned ( ) } else { [ Some ( & None ) ] . iter ( ) . cloned ( ) } ; if is_dragover_after_last && from_index . is_some ( ) { self . to_active_column_state ( Box :: new ( self . config . columns . iter ( ) . map ( Some ) . chain ( tail ) , ) ) } else if is_to_swap || is_from_required { let all_columns = self . config . columns . iter ( ) . filter_map ( move | x | match x { Some ( x ) if x == from_column => { if is_to_empty && ! is_from_swap { None } else { Some ( to_column . unwrap_or ( & None ) ) } } x => Some ( x ) , } ) ; let before_cols = all_columns . clone ( ) . pad_using ( min_cols , | _ | & None ) . take ( * to_index ) . map ( Some ) ; let after_cols = all_columns . skip ( * to_index + 1 ) . map ( Some ) ; self . to_active_column_state ( Box :: new ( before_cols . chain ( [ None ] . iter ( ) . cloned ( ) ) . chain ( after_cols ) . chain ( tail ) , ) ) } else { let to_offset = match to_column { Some ( Some ( _ ) ) => * to_index , _ => * to_index + 1 , } ; let all_columns = self . config . columns . iter ( ) . filter_map ( move | x | match x { Some ( x ) if x == from_column => { if ! is_from_swap { None } else { Some ( & None ) } } x => Some ( x ) , } ) ; let before_cols = all_columns . clone ( ) . pad_using ( min_cols , | _ | & None ) . take ( * to_index ) . map ( Some ) ; let after_cols = all_columns . skip ( to_offset ) . map ( Some ) ; self . to_active_column_state ( Box :: new ( before_cols . chain ( [ None ] . iter ( ) . cloned ( ) ) . chain ( after_cols ) . chain ( tail ) , ) ) } } _ => { let tail = if has_blank_tail { [ ] . iter ( ) . cloned ( ) } else { [ Some ( & None ) ] . iter ( ) . cloned ( ) } ; self . to_active_column_state ( Box :: new ( self . config . columns . iter ( ) . map ( Some ) . chain ( tail ) , ) ) } } }
Generate an iterator for active columns, which are represented as
`Option` for dragover and missing columns.
Generate an iterator for active columns which are represented as ` Option ` for dragover and missing columns .
&'a self
&'a self