Skip to content

Commit b806c39

Browse files
committed
Add expect_ident_cloned and expect_string_cloned
1 parent c305bcf commit b806c39

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/parser.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,12 @@ impl<'i: 't, 't> Parser<'i, 't> {
493493
}
494494
}
495495

496+
/// expect_ident, but clone the CowRcStr
497+
#[inline]
498+
pub fn expect_ident_cloned(&mut self) -> Result<CowRcStr<'i>, BasicParseError<'i>> {
499+
self.expect_ident().map(|s| s.clone())
500+
}
501+
496502
/// Parse a <ident-token> whose unescaped value is an ASCII-insensitive match for the given value.
497503
#[inline]
498504
pub fn expect_ident_matching(&mut self, expected_value: &str) -> Result<(), BasicParseError<'i>> {
@@ -511,6 +517,12 @@ impl<'i: 't, 't> Parser<'i, 't> {
511517
}
512518
}
513519

520+
/// expect_string, but clone the CowRcStr
521+
#[inline]
522+
pub fn expect_string_cloned(&mut self) -> Result<CowRcStr<'i>, BasicParseError<'i>> {
523+
self.expect_string().map(|s| s.clone())
524+
}
525+
514526
/// Parse either a <ident-token> or a <string-token>, and return the unescaped value.
515527
#[inline]
516528
pub fn expect_ident_or_string(&mut self) -> Result<&CowRcStr<'i>, BasicParseError<'i>> {

0 commit comments

Comments
 (0)