#[cfg(feature = "alloc")]
use alloc::string::{String, ToString};
pub trait RemoveFnl {
type Output;
fn remove_fnl(&self) -> Self::Output;
}
#[cfg(feature = "alloc")]
pub trait StringFmt {
fn kebab_case(&self) -> String;
fn dot_case(&self) -> String;
fn snake_case(&self) -> String;
fn title_case(&self) -> String;
}
impl<'a> RemoveFnl for &'a str {
type Output = &'a str;
fn remove_fnl(&self) -> Self::Output {
&self[1..self.len() - 1]
}
}
#[cfg(feature = "alloc")]
impl RemoveFnl for String {
type Output = String;
fn remove_fnl(&self) -> Self::Output {
self[1..self.len() - 1].to_string()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_remove_fnl() {
let s = "\"Hello, World!\"";
assert_eq!(s.chars().next(), Some('"'));
assert_eq!(s.remove_fnl(), "Hello, World!");
}
#[cfg(feature = "alloc")]
#[test]
fn test_remove_fnl_alloc() {
let s = String::from("\"Hello, World!\"");
assert_eq!(s.remove_fnl(), String::from("Hello, World!"));
}
}