1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::naming_conventions::delimiter_spaced::{build_string, parse_str};
use crate::CaseStyle;
use std::fmt::Debug;
pub trait Case: Debug {
fn parse_str(&self, input: &str) -> CaseStyle;
fn build_string(&self, obj: CaseStyle) -> String;
}
pub trait DelimiterSpaced: Debug {
fn spacing_char(&self) -> char;
fn do_uppercase(&self) -> bool {
false
}
}
impl<T> Case for T
where
T: DelimiterSpaced,
{
fn parse_str(&self, input: &str) -> CaseStyle {
parse_str(input, self.spacing_char())
}
fn build_string(&self, case_style: CaseStyle) -> String {
build_string(case_style, self.spacing_char(), self.do_uppercase())
}
}