pub(crate) struct ConstFnMutClosure<CapturedData, Function> {
    pub data: CapturedData,
    pub func: Function,
}
Expand description

Struct representing a closure with mutably borrowed data.

Example:

#![feature(const_mut_refs)]
use crate::const_closure::ConstFnMutClosure;
const fn imp(state: &mut i32, (arg,): (i32,)) -> i32 {
  *state += arg;
  *state
}
let mut i = 5;
let mut cl = ConstFnMutClosure::new(&mut i, imp);

assert!(7 == cl(2));
assert!(8 == cl(1));

Fields§

§data: CapturedData

The Data captured by the Closure. Must be either a (mutable) reference or a tuple of (mutable) references.

§func: Function

The Function of the Closure, must be: Fn(CapturedData, ClosureArgs) -> ClosureReturn

Implementations§

Function for creating a new closure.

data is the a mutable borrow of data that is captured from the environment. If you want Data to be a tuple of mutable Borrows, the struct must be constructed manually.

func is the function of the closure, it gets the data and a tuple of the arguments closure and return the return value of the closure.

Trait Implementations§

🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
The returned type after the call operator is used.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
The returned type after the call operator is used.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
The returned type after the call operator is used.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
The returned type after the call operator is used.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.
The returned type after the call operator is used.
🔬This is a nightly-only experimental API. (fn_traits #29625)
Performs the call operation.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

🔬This is a nightly-only experimental API. (pattern #27721)
Associated searcher for this pattern
🔬This is a nightly-only experimental API. (pattern #27721)
Constructs the associated searcher from self and the haystack to search in. Read more
🔬This is a nightly-only experimental API. (pattern #27721)
Checks whether the pattern matches anywhere in the haystack
🔬This is a nightly-only experimental API. (pattern #27721)
Checks whether the pattern matches at the front of the haystack
🔬This is a nightly-only experimental API. (pattern #27721)
Removes the pattern from the front of haystack, if it matches.
🔬This is a nightly-only experimental API. (pattern #27721)
Checks whether the pattern matches at the back of the haystack
🔬This is a nightly-only experimental API. (pattern #27721)
Removes the pattern from the back of haystack, if it matches.
🔬This is a nightly-only experimental API. (sized_type_properties)
true if this type requires no storage. false if its size is greater than zero. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.