Expand description
slicestring is a crate for slicing Strings.
It provides the slice() method for String and &str.
It takes the index-range as an argument, whereby also a negative value can be passed for the second index.
It slices the String or &str and returns a the sliced one as a String.
ยงExample:
use slicestring::Slice;
let mut s = "hello world!";
s = s.slice(..5);
assert_eq!("hello", s);It also works with emoticons since the slice() method takes into account characters.
let mut s = String::from("hello ๐");
s = s.slice(5..);
assert_eq!("๐", s);Traitsยง
- Slice
- Provides the [
slice()] method. [slice()]: trait.Slice.html#tymethod.slice