Skip to content

Commit 1c30bd1

Browse files
committed
Make Predicate allow ?Sized
1 parent 04e7b24 commit 1c30bd1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

evmap/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,27 +225,27 @@ pub use left_right::ReadGuard;
225225
///
226226
/// The predicate function is called once for each distinct value, and `true` if this is the
227227
/// _first_ call to the predicate on the _second_ application of the operation.
228-
pub struct Predicate<V>(pub(crate) Box<dyn FnMut(&V, bool) -> bool + Send>);
228+
pub struct Predicate<V: ?Sized>(pub(crate) Box<dyn FnMut(&V, bool) -> bool + Send>);
229229

230-
impl<V> Predicate<V> {
230+
impl<V: ?Sized> Predicate<V> {
231231
/// Evaluate the predicate for the given element
232232
#[inline]
233233
pub fn eval(&mut self, value: &V, reset: bool) -> bool {
234234
(*self.0)(value, reset)
235235
}
236236
}
237237

238-
impl<V> PartialEq for Predicate<V> {
238+
impl<V: ?Sized> PartialEq for Predicate<V> {
239239
#[inline]
240240
fn eq(&self, other: &Self) -> bool {
241241
// only compare data, not vtable: https://stackoverflow.com/q/47489449/472927
242242
&*self.0 as *const _ as *const () == &*other.0 as *const _ as *const ()
243243
}
244244
}
245245

246-
impl<V> Eq for Predicate<V> {}
246+
impl<V: ?Sized> Eq for Predicate<V> {}
247247

248-
impl<V> fmt::Debug for Predicate<V> {
248+
impl<V: ?Sized> fmt::Debug for Predicate<V> {
249249
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
250250
f.debug_tuple("Predicate")
251251
.field(&format_args!("{:p}", &*self.0 as *const _))

0 commit comments

Comments
 (0)