pub struct InlineFnOnce<'a, Sig: FnSig, const SIZE: usize = DEFAULT_INLINE_FN_SIZE, S = Local> { /* private fields */ }Expand description
An inline-stored, partially type-erased FnOnce closure with compile-time capacity SIZE.
Similar to C++ fit::inline_callback, InlineFnOnce stores a single-use callable inline
without heap allocation and consumes self upon invocation.
Implementations§
Source§impl<'a, Sig: FnSig, const SIZE: usize, S> InlineFnOnce<'a, Sig, SIZE, S>
impl<'a, Sig: FnSig, const SIZE: usize, S> InlineFnOnce<'a, Sig, SIZE, S>
Sourcepub fn new<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + 'a,
S: ThreadSafety<F>,
pub fn new<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + 'a,
S: ThreadSafety<F>,
Wraps a single-use closure inline, asserting at compile time that its size is
<= SIZE and alignment is <= 8.
Sourcepub fn resize<const NEW_SIZE: usize>(self) -> InlineFnOnce<'a, Sig, NEW_SIZE, S>
pub fn resize<const NEW_SIZE: usize>(self) -> InlineFnOnce<'a, Sig, NEW_SIZE, S>
Widens the inline storage capacity to NEW_SIZE bytes (NEW_SIZE >= SIZE).
Fails to compile if NEW_SIZE < SIZE.
Sourcepub fn into_local(self) -> InlineFnOnce<'a, Sig, SIZE, Local>
pub fn into_local(self) -> InlineFnOnce<'a, Sig, SIZE, Local>
Relaxes the thread-safety marker of this InlineFnOnce to Local (!Send + !Sync).
Source§impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, Local>
impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, Local>
Sourcepub fn new_local<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + 'a,
pub fn new_local<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + 'a,
Creates a local (!Send + !Sync) InlineFnOnce.
Source§impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, SendOnly>
impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, SendOnly>
Sourcepub fn new_send<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + Send + 'a,
pub fn new_send<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + Send + 'a,
Creates a Send (!Sync) InlineFnOnce.
Source§impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, SendSync>
impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, SendSync>
Sourcepub fn new_send_sync<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + Send + Sync + 'a,
pub fn new_send_sync<F>(closure: F) -> Selfwhere
F: FnOnceWithSig<Sig> + Send + Sync + 'a,
Creates a Send + Sync InlineFnOnce.
Source§impl<'a, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn() -> Ret, SIZE, S>
impl<'a, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn() -> Ret, SIZE, S>
Source§impl<'a, A1, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1) -> Ret, SIZE, S>
impl<'a, A1, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1) -> Ret, SIZE, S>
Source§impl<'a, A1, A2, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2) -> Ret, SIZE, S>
impl<'a, A1, A2, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2) -> Ret, SIZE, S>
Source§impl<'a, A1, A2, A3, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3) -> Ret, SIZE, S>
impl<'a, A1, A2, A3, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3) -> Ret, SIZE, S>
Source§impl<'a, A1, A2, A3, A4, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4) -> Ret, SIZE, S>
impl<'a, A1, A2, A3, A4, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4) -> Ret, SIZE, S>
Source§impl<'a, A1, A2, A3, A4, A5, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5) -> Ret, SIZE, S>
impl<'a, A1, A2, A3, A4, A5, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5) -> Ret, SIZE, S>
Source§impl<'a, A1, A2, A3, A4, A5, A6, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5, A6) -> Ret, SIZE, S>
impl<'a, A1, A2, A3, A4, A5, A6, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5, A6) -> Ret, SIZE, S>
Source§impl<'a, A1, A2, A3, A4, A5, A6, A7, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5, A6, A7) -> Ret, SIZE, S>
impl<'a, A1, A2, A3, A4, A5, A6, A7, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5, A6, A7) -> Ret, SIZE, S>
Source§impl<'a, A1, A2, A3, A4, A5, A6, A7, A8, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5, A6, A7, A8) -> Ret, SIZE, S>
impl<'a, A1, A2, A3, A4, A5, A6, A7, A8, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5, A6, A7, A8) -> Ret, SIZE, S>
Trait Implementations§
Source§impl<'a, Sig: FnSig, const SIZE: usize, S> Debug for InlineFnOnce<'a, Sig, SIZE, S>
impl<'a, Sig: FnSig, const SIZE: usize, S> Debug for InlineFnOnce<'a, Sig, SIZE, S>
Source§impl<'a, Sig: FnSig, const SIZE: usize, S> From<InlineFn<'a, Sig, SIZE, S>> for InlineFnOnce<'a, Sig, SIZE, S>
impl<'a, Sig: FnSig, const SIZE: usize, S> From<InlineFn<'a, Sig, SIZE, S>> for InlineFnOnce<'a, Sig, SIZE, S>
Source§impl<'a, Sig: FnSig, const SIZE: usize, S> From<InlineFnMut<'a, Sig, SIZE, S>> for InlineFnOnce<'a, Sig, SIZE, S>
impl<'a, Sig: FnSig, const SIZE: usize, S> From<InlineFnMut<'a, Sig, SIZE, S>> for InlineFnOnce<'a, Sig, SIZE, S>
Source§fn from(func: InlineFnMut<'a, Sig, SIZE, S>) -> Self
fn from(func: InlineFnMut<'a, Sig, SIZE, S>) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl<'a, Sig, const SIZE: usize = DEFAULT_INLINE_FN_SIZE, S = Local> !Freeze for InlineFnOnce<'a, Sig, SIZE, S>
impl<'a, Sig, const SIZE: usize = DEFAULT_INLINE_FN_SIZE, S = Local> !RefUnwindSafe for InlineFnOnce<'a, Sig, SIZE, S>
impl<'a, Sig, const SIZE: usize, S> Send for InlineFnOnce<'a, Sig, SIZE, S>where
S: Send,
impl<'a, Sig, const SIZE: usize, S> Sync for InlineFnOnce<'a, Sig, SIZE, S>where
S: Sync,
impl<'a, Sig, const SIZE: usize, S> Unpin for InlineFnOnce<'a, Sig, SIZE, S>where
<Sig as FnSig>::Trampoline: Unpin,
S: Unpin,
impl<'a, Sig, const SIZE: usize, S> UnsafeUnpin for InlineFnOnce<'a, Sig, SIZE, S>where
<Sig as FnSig>::Trampoline: UnsafeUnpin,
impl<'a, Sig, const SIZE: usize, S> UnwindSafe for InlineFnOnce<'a, Sig, SIZE, S>where
<Sig as FnSig>::Trampoline: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more