[−][src]Trait stdext::str::StrExt
Extension trait with useful methods for primitive type str
.
Required methods
fn splitn_exact<'a, P: Into<AltPattern<'a>>>(
&'a self,
n: usize,
pat: P
) -> Option<Vec<&'a str>>
&'a self,
n: usize,
pat: P
) -> Option<Vec<&'a str>>
Version of str::splitn
which expects the exact
amount of entries obtained after splitting. This method
returns Vec
, as SplitN
iterator depends on the unstable
type Pattern
and cannot be returned on the stable Rust.
Examples
use stdext::prelude::*; let data = "Hello world"; let splitted = data.splitn_exact(2, " ").unwrap(); assert_eq!(&splitted, &["Hello", "world"]); let splitted = data.splitn_exact(5, '-'); assert!(splitted.is_none());
Implementations on Foreign Types
impl<'_> StrExt for &'_ str
[src]
fn splitn_exact<'a, P: Into<AltPattern<'a>>>(
&'a self,
n: usize,
pat: P
) -> Option<Vec<&'a str>>
[src]
&'a self,
n: usize,
pat: P
) -> Option<Vec<&'a str>>