[][src]Function quoted_string::to_content

pub fn to_content<'a, Spec: GeneralQSSpec>(
    quoted_string: &'a str
) -> Result<Cow<'a, str>, CoreError>

converts a quoted string into it's content

This methods retrieves the content of a quoted-string, which means it strips the surrounding '"'-quoted, converts quoted-pairs into the values they represent and strips not-semantic character.

Example

//use your own Spec in practise
use quoted_string::test_utils::TestSpec;
use quoted_string::to_content;

let content = to_content::<TestSpec>("\"ab\\\"c\n\nde\"")
    .expect("only fails if the input is not a quoted string");
assert_eq!(&*content, "ab\"cde");

let content = to_content::<TestSpec>("\"simple\"").unwrap();
// to content will just use slicing to strip `'"'`-quotes if possible
assert_eq!(content, Cow::Borrowed("simple"));