split_string

Function split_string 

Source
pub fn split_string(phrase: String, separators: &[char]) -> Vec<String>
Expand description

Make the start of each word capital, splitting on sep.

ยงExamples

A simple phrase with a space.

use blogs_md_easy::split_string;

let phrase = "Hello World";
let phrase = split_string(phrase.to_string(), &[' ', '-']);
//let phrase = phrase.iter().map(|word| word.as_str()).collect::<&str>();
assert_eq!(phrase, vec!["Hello", " ", "World"]);

A name with a hyphen.

use blogs_md_easy::split_string;

let phrase = "John Doe-Bloggs";
let phrase = split_string(phrase.to_string(), &[' ', '-']);
//let phrase = phrase.iter().map(|word| word.as_str()).collect::<&str>();
assert_eq!(phrase, vec!["John", " ", "Doe", "-", "Bloggs"]);

Two separators in a row.

use blogs_md_easy::split_string;

let phrase = "Hello, World!";
let phrase = split_string(phrase.to_string(), &[' ', ',', '!']);
//let phrase = phrase.iter().map(|word| word.as_str()).collect::<&str>()
assert_eq!(phrase, vec!["Hello", ",", " ", "World", "!"]);