Skip to content

Commit 5eccdae

Browse files
committed
HRTB
1 parent 716200b commit 5eccdae

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/escapei.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ pub fn unescape(raw: &[u8]) -> Result<Cow<[u8]>, EscapeError> {
122122
/// # Pre-condition
123123
///
124124
/// The implementation of `lookup_custom_entity` is expected to operate over UTF-8 inputs.
125-
pub fn unescape_with<'a>(raw: &'a [u8], resolve_entity: impl Fn(&[u8]) -> Option<&str>) -> Result<Cow<'a, [u8]>, EscapeError> {
125+
pub fn unescape_with<'a, F>(raw: &'a [u8], resolve_entity: F) -> Result<Cow<'a, [u8]>, EscapeError>
126+
where
127+
F: for<'b> Fn(&'b [u8]) -> Option<&'b str>, // ie. the lifetime of the closure is decoupled from the output
128+
{
126129
let mut unescaped = None;
127130
let mut last_end = 0;
128131
let mut iter = memchr::memchr2_iter(b'&', b';', raw);

0 commit comments

Comments
 (0)