Remove unnecessary quote-stripping method (#3372)

This commit is contained in:
Charlie Marsh 2023-03-06 18:28:20 -05:00 committed by GitHub
parent 8437399496
commit c0ad875339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 24 deletions

View file

@ -38,22 +38,9 @@ pub fn is_upper(s: &str) -> bool {
cased
}
/// Remove prefixes (u, r, b) and quotes around a string. This expects the given
/// string to be a valid Python string representation, it doesn't do any
/// validation.
pub fn strip_quotes_and_prefixes(s: &str) -> &str {
match STRING_QUOTE_PREFIX_REGEX.captures(s) {
Some(caps) => match caps.name("raw") {
Some(m) => m.as_str(),
None => s,
},
None => s,
}
}
#[cfg(test)]
mod tests {
use crate::str::{is_lower, is_upper, strip_quotes_and_prefixes};
use crate::str::{is_lower, is_upper};
#[test]
fn test_is_lower() {
@ -76,12 +63,4 @@ mod tests {
assert!(!is_upper(""));
assert!(!is_upper("_"));
}
#[test]
fn test_strip_quotes_and_prefixes() {
assert_eq!(strip_quotes_and_prefixes(r#"'a'"#), "a");
assert_eq!(strip_quotes_and_prefixes(r#"bur'a'"#), "a");
assert_eq!(strip_quotes_and_prefixes(r#"UrB'a'"#), "a");
assert_eq!(strip_quotes_and_prefixes(r#""a""#), "a");
}
}