slicestring

Crates.ioslicestring
lib.rsslicestring
version0.3.3
sourcesrc
created_at2021-10-19 19:54:31.694874
updated_at2023-12-03 13:54:00.571946
descriptionslicestring is a crate for slicing Strings
homepage
repositoryhttps://github.com/floscodes/slicestring
max_upload_size
id467494
size5,476
flopetautschnig (floscodes)

documentation

README

slicestring

slicestring is a crate for slicing Strings. It provides the slice() method for String and &str. It takes a std::ops::Range as an argument. It slices the String or &str and returns the sliced one as a String.

Examples:

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.

use slicestring::Slice;

let mut s = String::from("hello 😃");
s = s.slice(5..);
assert_eq!("😃", s);
Commit count: 26

cargo fmt