@@ -16,7 +16,25 @@ const SERIAL_COOKIE_NO_RUNCONTAINER: u32 = 12346;
1616const SERIAL_COOKIE : u16 = 12347 ;
1717
1818impl RoaringBitmap {
19- pub fn union_with_serialized ( & mut self , mut reader : impl Read ) -> io:: Result < ( ) > {
19+ /// Returns the union between a roaring bitmap and a serialized roaring bitmap.
20+ ///
21+ /// Example
22+ /// =======
23+ ///
24+ /// ```
25+ /// use roaring::RoaringBitmap;
26+ ///
27+ /// let mut a = RoaringBitmap::from_sorted_iter(0..3000).unwrap();
28+ /// let b = RoaringBitmap::from_sorted_iter(2000..6000).unwrap();
29+ /// let union = &a | &b;
30+ ///
31+ /// let mut b_ser = Vec::new();
32+ /// b.serialize_into(&mut b_ser).unwrap();
33+ /// a.union_with_serialized_unchecked(&*b_ser).unwrap();
34+ ///
35+ /// assert_eq!(a, union);
36+ /// ```
37+ pub fn union_with_serialized_unchecked ( & mut self , mut reader : impl Read ) -> io:: Result < ( ) > {
2038 let ( size, has_offsets) = {
2139 let cookie = reader. read_u32 :: < LittleEndian > ( ) ?;
2240 if cookie == SERIAL_COOKIE_NO_RUNCONTAINER {
@@ -122,7 +140,7 @@ mod test {
122140
123141 let mut b_ser = Vec :: new( ) ;
124142 b. serialize_into( & mut b_ser) . unwrap( ) ;
125- a. union_with_serialized ( & * b_ser) . unwrap( ) ;
143+ a. union_with_serialized_unchecked ( & * b_ser) . unwrap( ) ;
126144
127145 prop_assert_eq!( a, union ) ;
128146 }
@@ -165,7 +183,7 @@ mod test {
165183
166184 let mut b_ser = Vec :: new ( ) ;
167185 b. serialize_into ( & mut b_ser) . unwrap ( ) ;
168- a. union_with_serialized ( & * b_ser) . unwrap ( ) ;
186+ a. union_with_serialized_unchecked ( & * b_ser) . unwrap ( ) ;
169187
170188 assert_eq ! ( a, union , "When testing: {a:?} | {b:?}" ) ;
171189 }
0 commit comments