Function string

Source
pub fn string<'a>(input: &mut &'a str) -> ModalResult<Cow<'a, str>>
Expand description

Parses a string literal until </, e.g., example in (example</).

  • The corresponding type kind: CString, StringPtr

§Examples

use serde_hkx::xml::de::parser::type_kind::string;
use std::borrow::Cow;
use winnow::Parser as _;
assert_eq!(string.parse_next(&mut "example</"), Ok("example".into()));
assert_eq!(
    string.parse_next(&mut "example</not_hkparam>"),
    Ok("example".into())
);

assert_eq!(string.parse_next(&mut "&#9216;</"), Ok("\u{2400}".into()));
let mut escaped =
    "This is a &lt;test&gt; &amp; &quot;example&quot; &apos; &#9216; &#x2400;</";
assert_eq!(
    string.parse_next(&mut escaped),
    Ok(Cow::Borrowed(
        "This is a <test> & \"example\" ' \u{2400} \u{2400}"
    ))
);

§Errors

When parse failed.