1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use ucfirst::ucfirst;

pub fn title_case<'a>(now: impl IntoIterator<Item = &'a str>, pre: &str) -> String {
  now
    .into_iter()
    .map(|i| {
      // i18n.site 欢迎您 -> Welcome To i18n.site
      if pre.contains(i) {
        i.into()
      } else {
        ucfirst(i)
      }
    })
    .collect::<Vec<_>>()
    .join(" ")
}