6 releases

0.3.3 Dec 3, 2023
0.3.2 Apr 17, 2022
0.3.1 Jan 9, 2022
0.2.1 Jan 8, 2022
0.1.0 Oct 19, 2021

#423 in Text processing

Download history 69/week @ 2023-12-18 13/week @ 2024-01-08 44/week @ 2024-01-15 32/week @ 2024-01-22 15/week @ 2024-01-29 6/week @ 2024-02-05 6/week @ 2024-02-12 18/week @ 2024-02-19 28/week @ 2024-02-26 19/week @ 2024-03-04 56/week @ 2024-03-11 13/week @ 2024-03-18 128/week @ 2024-04-01

199 downloads per month
Used in 2 crates

MIT/Apache

6KB
69 lines

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);

lib.rs:

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);

No runtime deps