@@ -489,6 +489,13 @@ impl AttributeColumns {
489489 self . columns . iter ( ) . find_map ( |( k, column) | if k == key { column. get_any ( index) ?. downcast_ref :: < T > ( ) } else { None } )
490490 }
491491
492+ /// Removes the entire column for the given key, if present.
493+ fn remove_column ( & mut self , key : & str ) {
494+ if let Some ( position) = self . columns . iter ( ) . position ( |( k, _) | k == key) {
495+ self . columns . remove ( position) ;
496+ }
497+ }
498+
492499 /// Finds or creates a column for the given key and type, returning its position.
493500 /// If a column with the key exists but has the wrong type, it is removed and replaced with a new column of the correct type, padded with defaults.
494501 /// A newly created column is filled with `T::default()` for all existing rows.
@@ -753,6 +760,11 @@ impl<T> Table<T> {
753760 self . attributes . set_value ( key, index, value) ;
754761 }
755762
763+ /// Removes the entire attribute column for the given key, if present.
764+ pub fn remove_attribute ( & mut self , key : & str ) {
765+ self . attributes . remove_column ( key) ;
766+ }
767+
756768 /// Runs the given closure on a mutable reference to the attribute value at the given row index,
757769 /// creating the column with defaults if it doesn't exist, and returns the closure's result.
758770 pub fn with_attribute_mut_or_default < U : Clone + Send + Sync + Default + Debug + PartialEq + CacheHash + ' static , R , F : FnOnce ( & mut U ) -> R > ( & mut self , key : & str , index : usize , f : F ) -> R {
0 commit comments