use std::fmt; use std::str::FromStr; /// Returns a vector of items parsed from a delimited string /// /// # Arguments /// /// * `input` input string to split and parse from /// * `delimiter` item delimiter pub fn parse_delimited(input: &str, delimiter: &str) -> Vec where T: FromStr, ::Err: fmt::Debug, { input .split(delimiter) .map(|v| { v.trim() .parse::() .expect(format!("Unable to parse '{}' from text '{}'", v, input).as_str()) }) .collect() } /// Returns a string with each element of the vector formatted and joined /// /// # Arguments /// /// * `join_str` the string to use to join the vector elements /// * `v` the vector with elements to join pub fn join_vec(join_str: &str, v: &Vec) -> String { v.iter() .map(|p| format!("{}", p)) .collect::>() .join(join_str) }