#![forbid(unsafe_code)]
#![forbid(missing_docs)]
#![forbid(non_fmt_panics)]
#![cfg_attr(not(test), no_std)]
pub fn ltrim<'a>(input: &'a impl AsRef<str>) -> &'a str {
input.as_ref().trim_start()
}
pub fn rtrim<'a>(input: &'a impl AsRef<str>) -> &'a str {
input.as_ref().trim_end()
}
pub fn trim<'a>(input: &'a impl AsRef<str>) -> &'a str {
input.as_ref().trim()
}
pub const QUOTES: [ char; 3 ] = [ '"', '\'', '`' ];
pub fn dequote<'a>(input: &'a impl AsRef<str>) -> &'a str {
let iref = input.as_ref();
let mut nqts: usize = 0;
for c in iref.chars() {
if QUOTES.contains(&c) {
nqts += 1;
} else {
break;
}
}
if nqts == 0 {
iref
} else {
let mut strip = 0;
for i in 0..nqts {
if iref.chars().nth_back(i) == iref.chars().nth(i) {
strip += 1;
} else {
break;
}
}
if strip == 0 {
iref
} else {
&iref[(strip)..(iref.len() - strip)]
}
}
}
#[cfg(test)]
mod trim_tests;
#[cfg(test)]
mod dequote_tests;