Skip to main content

InlineFnOnce

Struct InlineFnOnce 

Source
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>

Source

pub fn new<F>(closure: F) -> Self
where 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.

Source

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.

Source

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>

Source

pub fn new_local<F>(closure: F) -> Self
where F: FnOnceWithSig<Sig> + 'a,

Creates a local (!Send + !Sync) InlineFnOnce.

Source§

impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, SendOnly>

Source

pub fn new_send<F>(closure: F) -> Self
where F: FnOnceWithSig<Sig> + Send + 'a,

Creates a Send (!Sync) InlineFnOnce.

Source§

impl<'a, Sig: FnSig, const SIZE: usize> InlineFnOnce<'a, Sig, SIZE, SendSync>

Source

pub fn new_send_sync<F>(closure: F) -> Self
where F: FnOnceWithSig<Sig> + Send + Sync + 'a,

Creates a Send + Sync InlineFnOnce.

Source

pub fn into_send(self) -> InlineFnOnce<'a, Sig, SIZE, SendOnly>

Relaxes the thread-safety marker from SendSync to SendOnly.

Source§

impl<'a, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn() -> Ret, SIZE, S>

Source

pub fn call(self) -> Ret

Consumes self and invokes the underlying closure once.

Source§

impl<'a, A1, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1) -> Ret, SIZE, S>

Source

pub fn call(self, a1: A1) -> Ret

Consumes self and invokes the underlying closure once.

Source§

impl<'a, A1, A2, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2) -> Ret, SIZE, S>

Source

pub fn call(self, a1: A1, a2: A2) -> Ret

Consumes self and invokes the underlying closure once.

Source§

impl<'a, A1, A2, A3, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3) -> Ret, SIZE, S>

Source

pub fn call(self, a1: A1, a2: A2, a3: A3) -> Ret

Consumes self and invokes the underlying closure once.

Source§

impl<'a, A1, A2, A3, A4, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4) -> Ret, SIZE, S>

Source

pub fn call(self, a1: A1, a2: A2, a3: A3, a4: A4) -> Ret

Consumes self and invokes the underlying closure once.

Source§

impl<'a, A1, A2, A3, A4, A5, Ret, const SIZE: usize, S> InlineFnOnce<'a, fn(A1, A2, A3, A4, A5) -> Ret, SIZE, S>

Source

pub fn call(self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5) -> Ret

Consumes self and invokes the underlying closure once.

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>

Source

pub fn call(self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6) -> Ret

Consumes self and invokes the underlying closure once.

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>

Source

pub fn call(self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7) -> Ret

Consumes self and invokes the underlying closure once.

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>

Source

pub fn call( self, a1: A1, a2: A2, a3: A3, a4: A4, a5: A5, a6: A6, a7: A7, a8: A8, ) -> Ret

Consumes self and invokes the underlying closure once.

Trait Implementations§

Source§

impl<'a, Sig: FnSig, const SIZE: usize, S> Debug for InlineFnOnce<'a, Sig, SIZE, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, Sig: FnSig, const SIZE: usize, S> From<InlineFn<'a, Sig, SIZE, S>> for InlineFnOnce<'a, Sig, SIZE, S>

Source§

fn from(func: InlineFn<'a, Sig, SIZE, S>) -> Self

Converts to this type from the input type.
Source§

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

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 T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

Source§

impl<T> ToMutPtr for T
where T: ?Sized,

Source§

type Target = T

The target type of the pointer.
Source§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.