std-method
Vec::extend_from_within
Append clones of elements from a range of the same vector. The range must refer to elements that already exist before extension. Expected stdout (not executed): [1, 2, 3, 2, 3] Common mistake: Using an out-of-bounds source range.
Formal Syntax & Structure
rust syntaxrust
vector.extend_from_within(range)Working Example
Example Snippetrust
fn main() { let mut pattern = vec![1, 2, 3]; pattern.extend_from_within(1..); println!("{pattern:?}");}