diff --git a/src/impls/slice_copy.rs b/src/impls/slice_copy.rs index 05fba73..01d9b93 100644 --- a/src/impls/slice_copy.rs +++ b/src/impls/slice_copy.rs @@ -72,8 +72,28 @@ where impl ReserveItems> for &[T] { fn reserve_items(target: &mut CopyRegion, items: I) + where + I: Iterator + Clone, + { + target.slices.reserve(items.clone().map(|i| i.len()).sum()); + } +} + +impl CopyOnto> for &Vec where - I: Iterator + Clone, + T: Copy, +{ + fn copy_onto(self, target: &mut CopyRegion) -> as Region>::Index { + let start = target.slices.len(); + target.slices.extend_from_slice(self); + (start, target.slices.len()) + } +} + +impl ReserveItems> for &Vec { + fn reserve_items(target: &mut CopyRegion, items: I) + where + I: Iterator + Clone, { target.slices.reserve(items.clone().map(|i| i.len()).sum()); } diff --git a/src/impls/string.rs b/src/impls/string.rs index bbde61b..3e720a9 100644 --- a/src/impls/string.rs +++ b/src/impls/string.rs @@ -92,10 +92,19 @@ impl CopyOnto for &&str { } impl ReserveItems for &str { + fn reserve_items(target: &mut StringRegion, items: I) + where + I: Iterator + Clone, + { + ReserveItems::reserve_items(&mut target.inner, items.map(str::as_bytes)) + } +} + +impl ReserveItems for &&str { fn reserve_items(target: &mut StringRegion, items: I) where I: Iterator + Clone, { - ReserveItems::reserve_items(&mut target.inner, items.map(str::as_bytes)) + ReserveItems::reserve_items(&mut target.inner, items.map(|s| s.as_bytes())) } }