Skip to main content

strip_quotes

Function strip_quotes 

Source
pub fn strip_quotes(
    input: &str,
) -> Result<QuoteStripped<'_>, UnclosedQuotesError<'_>>
Expand description

Strip quotes from an input, given that both quotes use either " or ', but not both.

§Example

assert_eq!(
    strip_quotes("\"Helvetica\""),
    Ok(QuoteStripped("Helvetica"))
);
assert_eq!(strip_quotes("'Arial'"), Ok(QuoteStripped("Arial")));
assert_eq!(
    strip_quotes("\"Arial'"),
    Err(UnclosedQuotesError("\"Arial'"))
);

§Errors

Returns an error if input has an opening quote with no matching closing quote.