From d57c5b0b3f0580b042cb579182c0540243f1a6e5 Mon Sep 17 00:00:00 2001 From: myrrlyn Date: Sun, 18 Apr 2021 21:04:58 +0000 Subject: [PATCH] Address #53 --- lexical-core/src/util/sequence.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lexical-core/src/util/sequence.rs b/lexical-core/src/util/sequence.rs index 14bead0f..ac8b7e83 100644 --- a/lexical-core/src/util/sequence.rs +++ b/lexical-core/src/util/sequence.rs @@ -87,11 +87,14 @@ pub fn insert_many(vec: &mut V, index: usize, iterable: I) ptr::copy(ptr.add(lower_size_bound), ptr.add(num_added), old_len - index); } - vec.set_len(old_len + num_added); - // If the iterator had more than its lower bound indicated, collect in // a slow path. - vec.extend(iter); + for elem in iter { + vec.insert(index + num_added, elem); + num_added += 1; + } + + vec.set_len(old_len + num_added); } }