Skip to main content

split_num_words

Function split_num_words 

Source
pub fn split_num_words(
    value: &str,
    sep: &str,
    min_num_words: usize,
    fill_from_start: bool,
) -> Vec<Option<String>>
Expand description

Perform a split on a value and return N words with None for missing parts.

§Arguments

  • value - The string to split
  • sep - The separator
  • min_num_words - Minimum number of words in result
  • fill_from_start - If true, pad with None at start; otherwise at end

§Example

use polyglot_sql::helper::split_num_words;

assert_eq!(
    split_num_words("db.table", ".", 3, true),
    vec![None, Some("db".to_string()), Some("table".to_string())]
);
assert_eq!(
    split_num_words("db.table", ".", 3, false),
    vec![Some("db".to_string()), Some("table".to_string()), None]
);