Function mortal::util::prefixes [] [src]

Important traits for Prefixes<'a>
pub fn prefixes(s: &str) -> Prefixes

Returns an iterator over all non-empty prefixes of s, beginning with the shortest.

If s is an empty string, the iterator will yield no elements.

Examples

let mut pfxs = prefixes("foo");

assert_eq!(pfxs.next(), Some("f"));
assert_eq!(pfxs.next(), Some("fo"));
assert_eq!(pfxs.next(), Some("foo"));
assert_eq!(pfxs.next(), None);