Crates.io | slicestring |
lib.rs | slicestring |
version | 0.3.3 |
source | src |
created_at | 2021-10-19 19:54:31.694874 |
updated_at | 2023-12-03 13:54:00.571946 |
description | slicestring is a crate for slicing Strings |
homepage | |
repository | https://github.com/floscodes/slicestring |
max_upload_size | |
id | 467494 |
size | 5,476 |
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
.
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);