1#[cfg(feature = "alloc")]
7use alloc::string::{String, ToString};
8
9pub trait RemoveFnl {
14 type Output;
15
16 fn remove_fnl(&self) -> Self::Output;
17}
18#[cfg(feature = "alloc")]
21pub trait StringFmt {
22 fn kebab_case(&self) -> String;
24 fn dot_case(&self) -> String;
26 fn snake_case(&self) -> String;
28 fn title_case(&self) -> String;
30}
31
32impl<'a> RemoveFnl for &'a str {
37 type Output = &'a str;
38
39 fn remove_fnl(&self) -> Self::Output {
40 &self[1..self.len() - 1]
41 }
42}
43
44#[cfg(feature = "alloc")]
45impl RemoveFnl for String {
46 type Output = String;
47
48 fn remove_fnl(&self) -> Self::Output {
49 self[1..self.len() - 1].to_string()
50 }
51}
52
53#[cfg(test)]
54mod tests {
55 use super::*;
56
57 #[test]
58 fn test_remove_fnl() {
59 let s = "\"Hello, World!\"";
60 assert_eq!(s.chars().next(), Some('"'));
61 assert_eq!(s.remove_fnl(), "Hello, World!");
62 }
63
64 #[cfg(feature = "alloc")]
65 #[test]
66 fn test_remove_fnl_alloc() {
67 let s = String::from("\"Hello, World!\"");
68 assert_eq!(s.remove_fnl(), String::from("Hello, World!"));
69 }
70}