resize slice (2)
Enlarge and shrink slices (given a larger slice) in safe Rust.
Not to be confused with resize-slice, which can only shrink slices and uses unsafe 👻
Example
use ResizeSlice;
let source = &;
let slice = &source;
assert_eq!;
let resized = slice.try_resize.unwrap;
assert_eq!;
So a range of 1..-1 would move the start one to the right and move the end one to the left.
source: |------------------------|
slice: |-------|
result: |---|
A range of 1.. would move the start one to the right and fully expand the end.
source: |------------------------|
slice: |-------|
result: |-----------|
A range of 0..0 would return the same slice.
source: |------------------------|
slice: |-------|
result: |-------|