pub fn cleanup_rawstring(raw_string: &str) -> &str {
let len = raw_string.len();
if len <= 2 {
""
} else {
&raw_string[1..len - 1]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn empty_string_returns_empty_string() {
assert_eq!("", cleanup_rawstring(r#""#));
assert_eq!("", cleanup_rawstring(r#""""#));
assert_eq!("", cleanup_rawstring(r#"''"#));
}
#[test]
fn string_is_cleaned_as_expected() {
assert_eq!(
"https://github.com/Sighery/rustympkg",
cleanup_rawstring(r#"'https://github.com/Sighery/rustympkg'"#)
);
assert_eq!(
"https://github.com/Sighery/rustympkg",
cleanup_rawstring(r#""https://github.com/Sighery/rustympkg""#)
);
}
}