pub struct CustomFn(pub fn(&WorkerCtx<'_>) -> WorkerReport);Expand description
Function-pointer wrapper for the
WorkType::Custom variant’s run field.
Wrapping the fn pointer in a newtype lets WorkType
#[derive(PartialEq)] succeed — bare fn pointers do not
implement PartialEq, so the enum derive would otherwise
fail. The manual PartialEq impl below compares function
addresses via std::ptr::fn_addr_eq (stable since Rust
1.85.0), the canonical address-comparison primitive for fn
pointers: per its rustdoc, address equality is sufficient to
conclude that calling both functions is equivalent.
§Caveat: address equality is one-direction-only
fn_addr_eq may return false even for two CustomFn
wrapping the SAME fn item — fn-item-to-fn-pointer coercion
can yield distinct addresses for the same item across multiple
coercion sites (rustc + LLVM linker behavior; cross-crate
references especially). Two CustomFns comparing equal IS a
reliable “calls the same function” signal; comparing unequal
is NOT a reliable “calls a different function” signal. Tests
that rely on assert_eq!(custom_a, custom_b) between separate
coercion sites may flake — prefer comparing the variant name
(the WorkType::Custom { name, .. } field) when test intent
is “same logical custom workload.”
Copy + Clone mirror the underlying fn pointer (fn
pointers are Copy); Debug formats the address. No
serde derives — the parent WorkType::Custom variant
carries #[serde(skip)] because a fn pointer has no
portable wire format.
Tuple Fields§
§0: fn(&WorkerCtx<'_>) -> WorkerReportImplementations§
Trait Implementations§
impl Copy for CustomFn
Auto Trait Implementations§
impl Freeze for CustomFn
impl RefUnwindSafe for CustomFn
impl Send for CustomFn
impl Sync for CustomFn
impl Unpin for CustomFn
impl UnwindSafe for CustomFn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more