@@ -520,6 +520,35 @@ where
520520 { 
521521 Splice :: new ( self ,  range,  replace_with. into_iter ( ) ) 
522522 } 
523+ 
524+  /// Moves all key-value pairs from `other` into `self`, leaving `other` empty. 
525+   /// 
526+   /// This is equivalent to calling [`insert`][Self::insert] for each 
527+   /// key-value pair from `other` in order, which means that for keys that 
528+   /// already exist in `self`, their value is updated in the current position. 
529+   /// 
530+   /// # Examples 
531+   /// 
532+   /// ``` 
533+   /// use indexmap::IndexMap; 
534+   /// 
535+   /// // Note: Key (3) is present in both maps. 
536+   /// let mut a = IndexMap::from([(3, "c"), (2, "b"), (1, "a")]); 
537+   /// let mut b = IndexMap::from([(3, "d"), (4, "e"), (5, "f")]); 
538+   /// let old_capacity = b.capacity(); 
539+   /// 
540+   /// a.append(&mut b); 
541+   /// 
542+   /// assert_eq!(a.len(), 5); 
543+   /// assert_eq!(b.len(), 0); 
544+   /// assert_eq!(b.capacity(), old_capacity); 
545+   /// 
546+   /// assert!(a.keys().eq(&[3, 2, 1, 4, 5])); 
547+   /// assert_eq!(a[&3], "d"); // "c" was overwritten. 
548+   /// ``` 
549+   pub  fn  append < S2 > ( & mut  self ,  other :  & mut  IndexMap < K ,  V ,  S2 > )  { 
550+  self . extend ( other. drain ( ..) ) ; 
551+  } 
523552} 
524553
525554impl < K ,  V ,  S >  IndexMap < K ,  V ,  S > 
0 commit comments