#strings #slice #substr #substring #cut

slicestring

slicestring is a crate for slicing Strings

5 unstable releases

0.3.2 Apr 17, 2022
0.3.1 Jan 9, 2022
0.2.1 Jan 8, 2022
0.1.3 Dec 22, 2021
0.1.0 Oct 19, 2021

#421 in Text processing

Download history 10/week @ 2022-11-24 8/week @ 2022-12-01 41/week @ 2022-12-08 17/week @ 2022-12-15 14/week @ 2022-12-22 11/week @ 2022-12-29 9/week @ 2023-01-05 9/week @ 2023-01-12 20/week @ 2023-01-19 20/week @ 2023-01-26 30/week @ 2023-02-02 34/week @ 2023-02-09 81/week @ 2023-02-16 18/week @ 2023-02-23 20/week @ 2023-03-02 10/week @ 2023-03-09

135 downloads per month
Used in 2 crates

MIT/Apache

5KB
69 lines

slicestring

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