@@ -299,18 +299,7 @@ where
299
299
///
300
300
/// Its effects will not be exposed to readers until you call [`publish`](Self::publish).
301
301
pub fn append ( & mut self , op : O ) -> & mut Self {
302
- if self . first {
303
- // Safety: we know there are no outstanding w_handle readers, since we haven't
304
- // refreshed ever before, so we can modify it directly!
305
- let mut w_inner = self . raw_write_handle ( ) ;
306
- let w_inner = unsafe { w_inner. as_mut ( ) } ;
307
- let r_handle = self . enter ( ) . expect ( "map has not yet been destroyed" ) ;
308
- // Because we are operating directly on the map, and nothing is aliased, we do want
309
- // to perform drops, so we invoke absorb_second.
310
- Absorb :: absorb_second ( w_inner, op, & * r_handle) ;
311
- } else {
312
- self . oplog . push_back ( op) ;
313
- }
302
+ self . extend ( std:: iter:: once ( op) ) ;
314
303
self
315
304
}
316
305
@@ -340,6 +329,34 @@ where
340
329
}
341
330
}
342
331
332
+ impl < T , O > Extend < O > for WriteHandle < T , O >
333
+ where
334
+ T : Absorb < O > ,
335
+ {
336
+ /// Add multiple operations to the operational log.
337
+ ///
338
+ /// Their effects will not be exposed to readers until you call [`publish`](Self::publish)
339
+ fn extend < I > ( & mut self , ops : I )
340
+ where
341
+ I : IntoIterator < Item = O > ,
342
+ {
343
+ if self . first {
344
+ // Safety: we know there are no outstanding w_handle readers, since we haven't
345
+ // refreshed ever before, so we can modify it directly!
346
+ let mut w_inner = self . raw_write_handle ( ) ;
347
+ let w_inner = unsafe { w_inner. as_mut ( ) } ;
348
+ let r_handle = self . enter ( ) . expect ( "map has not yet been destroyed" ) ;
349
+ // Because we are operating directly on the map, and nothing is aliased, we do want
350
+ // to perform drops, so we invoke absorb_second.
351
+ for op in ops {
352
+ Absorb :: absorb_second ( w_inner, op, & * r_handle) ;
353
+ }
354
+ } else {
355
+ self . oplog . extend ( ops) ;
356
+ }
357
+ }
358
+ }
359
+
343
360
/// `WriteHandle` can be sent across thread boundaries:
344
361
///
345
362
/// ```
0 commit comments