Skip to content

Commit

Permalink
HRTB
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed Jul 11, 2022
1 parent 716200b commit 5eccdae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/escapei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ pub fn unescape(raw: &[u8]) -> Result<Cow<[u8]>, EscapeError> {
/// # Pre-condition
///
/// The implementation of `lookup_custom_entity` is expected to operate over UTF-8 inputs.
pub fn unescape_with<'a>(raw: &'a [u8], resolve_entity: impl Fn(&[u8]) -> Option<&str>) -> Result<Cow<'a, [u8]>, EscapeError> {
pub fn unescape_with<'a, F>(raw: &'a [u8], resolve_entity: F) -> Result<Cow<'a, [u8]>, EscapeError>
where
F: for<'b> Fn(&'b [u8]) -> Option<&'b str>, // ie. the lifetime of the closure is decoupled from the output
{
let mut unescaped = None;
let mut last_end = 0;
let mut iter = memchr::memchr2_iter(b'&', b';', raw);
Expand Down

0 comments on commit 5eccdae

Please sign in to comment.