pub struct DynamicFunctionMut<'env> { /* private fields */ }
Expand description
A dynamic representation of a function.
This type can be used to represent any callable that satisfies FnMut
(or the reflection-based equivalent, ReflectFnMut
).
That is, any function or closure.
For functions that do not need to capture their environment mutably,
it’s recommended to use DynamicFunction
instead.
This type can be seen as a superset of DynamicFunction
.
See the module-level documentation for more information.
You will generally not need to construct this manually.
Instead, many functions and closures can be automatically converted using the IntoFunctionMut
trait.
§Example
Most of the time, a DynamicFunctionMut
can be created using the IntoFunctionMut
trait:
let mut list: Vec<i32> = vec![1, 2, 3];
// `replace` is a closure that captures a mutable reference to `list`
let mut replace = |index: usize, value: i32| -> i32 {
let old_value = list[index];
list[index] = value;
old_value
};
// Since this closure mutably borrows data, we can't convert it into a regular `DynamicFunction`,
// as doing so would result in a compile-time error:
// let mut func: DynamicFunction = replace.into_function();
// Instead, we convert it into a `DynamicFunctionMut` using `IntoFunctionMut::into_function_mut`:
let mut func: DynamicFunctionMut = replace.into_function_mut();
// Dynamically call it:
let args = ArgList::default().with_owned(1_usize).with_owned(-2_i32);
let value = func.call(args).unwrap().unwrap_owned();
// Check the result:
assert_eq!(value.try_take::<i32>().unwrap(), 2);
// Note that `func` still has a reference to `list`,
// so we need to drop it before we can access `list` again.
// Alternatively, we could have invoked `func` with
// `DynamicFunctionMut::call_once` to immediately consume it.
drop(func);
assert_eq!(list, vec![1, -2, 3]);
Implementations§
Source§impl<'env> DynamicFunctionMut<'env>
impl<'env> DynamicFunctionMut<'env>
Sourcepub fn new<F>(
func: F,
info: impl TryInto,
) -> DynamicFunctionMut<'env>where
F: for<'a> FnMut(ArgList<'a>) -> Result<Return<'a>, FunctionError> + 'env,
<impl TryInto<FunctionInfo> as TryInto<FunctionInfo>>::Error: Debug,
pub fn new<F>(
func: F,
info: impl TryInto,
) -> DynamicFunctionMut<'env>where
F: for<'a> FnMut(ArgList<'a>) -> Result<Return<'a>, FunctionError> + 'env,
<impl TryInto<FunctionInfo> as TryInto<FunctionInfo>>::Error: Debug,
Create a new DynamicFunctionMut
.
The given function can be used to call out to any other callable, including functions, closures, or methods.
It’s important that the function signature matches the provided FunctionInfo
.
as this will be used to validate arguments when calling the function.
This is also required in order for function overloading to work correctly.
§Panics
This function may panic for any of the following reasons:
- No
SignatureInfo
is provided. - A provided
SignatureInfo
has more arguments thanArgCount::MAX_COUNT
. - The conversion to
FunctionInfo
fails.
Sourcepub fn with_name(
self,
name: impl Into<Cow<'static, str>>,
) -> DynamicFunctionMut<'env>
pub fn with_name( self, name: impl Into<Cow<'static, str>>, ) -> DynamicFunctionMut<'env>
Set the name of the function.
For DynamicFunctionMuts
created using IntoFunctionMut
,
the default name will always be the full path to the function as returned by core::any::type_name
,
unless the function is a closure, anonymous function, or function pointer,
in which case the name will be None
.
Sourcepub fn with_overload<'a, F, Marker>(self, function: F) -> DynamicFunctionMut<'a>where
'env: 'a,
F: IntoFunctionMut<'a, Marker>,
pub fn with_overload<'a, F, Marker>(self, function: F) -> DynamicFunctionMut<'a>where
'env: 'a,
F: IntoFunctionMut<'a, Marker>,
Add an overload to this function.
Overloads allow a single DynamicFunctionMut
to represent multiple functions of different signatures.
This can be used to handle multiple monomorphizations of a generic function or to allow functions with a variable number of arguments.
Any functions with the same argument signature will be overwritten by the one from the new function, F
.
For example, if the existing function had the signature (i32, i32) -> i32
,
and the new function, F
, also had the signature (i32, i32) -> i32
,
the one from F
would replace the one from the existing function.
Overloaded functions retain the name of the original function.
Note that it may be impossible to overload closures that mutably borrow from their environment due to Rust’s borrowing rules. However, it’s still possible to overload functions that do not capture their environment mutably, or those that maintain mutually exclusive mutable references to their environment.
§Panics
Panics if the function, F
, contains a signature already found in this function.
For a non-panicking version, see try_with_overload
.
§Example
let mut total_i32 = 0;
let mut add_i32 = |a: i32| total_i32 += a;
let mut total_f32 = 0.0;
let mut add_f32 = |a: f32| total_f32 += a;
// Currently, the only generic type `func` supports is `i32`.
let mut func = add_i32.into_function_mut();
// However, we can add an overload to handle `f32` as well:
func = func.with_overload(add_f32);
// Test `i32`:
let args = bevy_reflect::func::ArgList::new().with_owned(123_i32);
func.call(args).unwrap();
// Test `f32`:
let args = bevy_reflect::func::ArgList::new().with_owned(1.23_f32);
func.call(args).unwrap();
drop(func);
assert_eq!(total_i32, 123);
assert_eq!(total_f32, 1.23);
Sourcepub fn try_with_overload<F, Marker>(
self,
function: F,
) -> Result<DynamicFunctionMut<'env>, (Box<DynamicFunctionMut<'env>>, FunctionOverloadError)>where
F: IntoFunctionMut<'env, Marker>,
pub fn try_with_overload<F, Marker>(
self,
function: F,
) -> Result<DynamicFunctionMut<'env>, (Box<DynamicFunctionMut<'env>>, FunctionOverloadError)>where
F: IntoFunctionMut<'env, Marker>,
Attempt to add an overload to this function.
If the function, F
, contains a signature already found in this function,
an error will be returned along with the original function.
For a panicking version, see with_overload
.
Sourcepub fn call<'a>(
&mut self,
args: ArgList<'a>,
) -> Result<Return<'a>, FunctionError>
pub fn call<'a>( &mut self, args: ArgList<'a>, ) -> Result<Return<'a>, FunctionError>
Call the function with the given arguments.
Variables that are captured mutably by this function
won’t be usable until this function is dropped.
Consider using call_once
if you want to consume the function
immediately after calling it.
§Example
let mut total = 0;
let add = |a: i32, b: i32| -> i32 {
total = a + b;
total
};
let mut func = add.into_function_mut().with_name("add");
let args = ArgList::new().with_owned(25_i32).with_owned(75_i32);
let result = func.call(args).unwrap().unwrap_owned();
assert_eq!(result.try_take::<i32>().unwrap(), 100);
§Errors
This method will return an error if the number of arguments provided does not match
the number of arguments expected by the function’s FunctionInfo
.
The function itself may also return any errors it needs to.
Sourcepub fn call_once(self, args: ArgList<'_>) -> Result<Return<'_>, FunctionError>
pub fn call_once(self, args: ArgList<'_>) -> Result<Return<'_>, FunctionError>
Call the function with the given arguments and consume it.
This is useful for functions that capture their environment mutably because otherwise any captured variables would still be borrowed by it.
§Example
let mut count = 0;
let increment = |amount: i32| count += amount;
let increment_function = increment.into_function_mut();
let args = ArgList::new().with_owned(5_i32);
// We need to drop `increment_function` here so that we
// can regain access to `count`.
// `call_once` does this automatically for us.
increment_function.call_once(args).unwrap();
assert_eq!(count, 5);
§Errors
This method will return an error if the number of arguments provided does not match
the number of arguments expected by the function’s FunctionInfo
.
The function itself may also return any errors it needs to.
Examples found in repository?
19fn main() {
20 // There are times when it may be helpful to store a function away for later.
21 // In Rust, we can do this by storing either a function pointer or a function trait object.
22 // For example, say we wanted to store the following function:
23 fn add(left: i32, right: i32) -> i32 {
24 left + right
25 }
26
27 // We could store it as either of the following:
28 let fn_pointer: fn(i32, i32) -> i32 = add;
29 let fn_trait_object: Box<dyn Fn(i32, i32) -> i32> = Box::new(add);
30
31 // And we can call them like so:
32 let result = fn_pointer(2, 2);
33 assert_eq!(result, 4);
34 let result = fn_trait_object(2, 2);
35 assert_eq!(result, 4);
36
37 // However, you'll notice that we have to know the types of the arguments and return value at compile time.
38 // This means there's not really a way to store or call these functions dynamically at runtime.
39 // Luckily, Bevy's reflection crate comes with a set of tools for doing just that!
40 // We do this by first converting our function into the reflection-based `DynamicFunction` type
41 // using the `IntoFunction` trait.
42 let function: DynamicFunction<'static> = dbg!(add.into_function());
43
44 // This time, you'll notice that `DynamicFunction` doesn't take any information about the function's arguments or return value.
45 // This is because `DynamicFunction` checks the types of the arguments and return value at runtime.
46 // Now we can generate a list of arguments:
47 let args: ArgList = dbg!(ArgList::new().with_owned(2_i32).with_owned(2_i32));
48
49 // And finally, we can call the function.
50 // This returns a `Result` indicating whether the function was called successfully.
51 // For now, we'll just unwrap it to get our `Return` value,
52 // which is an enum containing the function's return value.
53 let return_value: Return = dbg!(function.call(args).unwrap());
54
55 // The `Return` value can be pattern matched or unwrapped to get the underlying reflection data.
56 // For the sake of brevity, we'll just unwrap it here and downcast it to the expected type of `i32`.
57 let value: Box<dyn PartialReflect> = return_value.unwrap_owned();
58 assert_eq!(value.try_take::<i32>().unwrap(), 4);
59
60 // The same can also be done for closures that capture references to their environment.
61 // Closures that capture their environment immutably can be converted into a `DynamicFunction`
62 // using the `IntoFunction` trait.
63 let minimum = 5;
64 let clamp = |value: i32| value.max(minimum);
65
66 let function: DynamicFunction = dbg!(clamp.into_function());
67 let args = dbg!(ArgList::new().with_owned(2_i32));
68 let return_value = dbg!(function.call(args).unwrap());
69 let value: Box<dyn PartialReflect> = return_value.unwrap_owned();
70 assert_eq!(value.try_take::<i32>().unwrap(), 5);
71
72 // We can also handle closures that capture their environment mutably
73 // using the `IntoFunctionMut` trait.
74 let mut count = 0;
75 let increment = |amount: i32| count += amount;
76
77 let closure: DynamicFunctionMut = dbg!(increment.into_function_mut());
78 let args = dbg!(ArgList::new().with_owned(5_i32));
79
80 // Because `DynamicFunctionMut` mutably borrows `total`,
81 // it will need to be dropped before `total` can be accessed again.
82 // This can be done manually with `drop(closure)` or by using the `DynamicFunctionMut::call_once` method.
83 dbg!(closure.call_once(args).unwrap());
84 assert_eq!(count, 5);
85
86 // Generic functions can also be converted into a `DynamicFunction`,
87 // however, they will need to be manually monomorphized first.
88 fn stringify<T: ToString>(value: T) -> String {
89 value.to_string()
90 }
91
92 // We have to manually specify the concrete generic type we want to use.
93 let function = stringify::<i32>.into_function();
94
95 let args = ArgList::new().with_owned(123_i32);
96 let return_value = function.call(args).unwrap();
97 let value: Box<dyn PartialReflect> = return_value.unwrap_owned();
98 assert_eq!(value.try_take::<String>().unwrap(), "123");
99
100 // To make things a little easier, we can also "overload" functions.
101 // This makes it so that a single `DynamicFunction` can represent multiple functions,
102 // and the correct one is chosen based on the types of the arguments.
103 // Each function overload must have a unique argument signature.
104 let function = stringify::<i32>
105 .into_function()
106 .with_overload(stringify::<f32>);
107
108 // Now our `function` accepts both `i32` and `f32` arguments.
109 let args = ArgList::new().with_owned(1.23_f32);
110 let return_value = function.call(args).unwrap();
111 let value: Box<dyn PartialReflect> = return_value.unwrap_owned();
112 assert_eq!(value.try_take::<String>().unwrap(), "1.23");
113
114 // Function overloading even allows us to have a variable number of arguments.
115 let function = (|| 0)
116 .into_function()
117 .with_overload(|a: i32| a)
118 .with_overload(|a: i32, b: i32| a + b)
119 .with_overload(|a: i32, b: i32, c: i32| a + b + c);
120
121 let args = ArgList::new()
122 .with_owned(1_i32)
123 .with_owned(2_i32)
124 .with_owned(3_i32);
125 let return_value = function.call(args).unwrap();
126 let value: Box<dyn PartialReflect> = return_value.unwrap_owned();
127 assert_eq!(value.try_take::<i32>().unwrap(), 6);
128
129 // As stated earlier, `IntoFunction` works for many kinds of simple functions.
130 // Functions with non-reflectable arguments or return values may not be able to be converted.
131 // Generic functions are also not supported (unless manually monomorphized like `foo::<i32>.into_function()`).
132 // Additionally, the lifetime of the return value is tied to the lifetime of the first argument.
133 // However, this means that many methods (i.e. functions with a `self` parameter) are also supported:
134 #[derive(Reflect, Default)]
135 struct Data {
136 value: String,
137 }
138
139 impl Data {
140 fn set_value(&mut self, value: String) {
141 self.value = value;
142 }
143
144 // Note that only `&'static str` implements `Reflect`.
145 // To get around this limitation we can use `&String` instead.
146 fn get_value(&self) -> &String {
147 &self.value
148 }
149 }
150
151 let mut data = Data::default();
152
153 let set_value = dbg!(Data::set_value.into_function());
154 let args = dbg!(ArgList::new().with_mut(&mut data)).with_owned(String::from("Hello, world!"));
155 dbg!(set_value.call(args).unwrap());
156 assert_eq!(data.value, "Hello, world!");
157
158 let get_value = dbg!(Data::get_value.into_function());
159 let args = dbg!(ArgList::new().with_ref(&data));
160 let return_value = dbg!(get_value.call(args).unwrap());
161 let value: &dyn PartialReflect = return_value.unwrap_ref();
162 assert_eq!(value.try_downcast_ref::<String>().unwrap(), "Hello, world!");
163
164 // For more complex use cases, you can always create a custom `DynamicFunction` manually.
165 // This is useful for functions that can't be converted via the `IntoFunction` trait.
166 // For example, this function doesn't implement `IntoFunction` due to the fact that
167 // the lifetime of the return value is not tied to the lifetime of the first argument.
168 fn get_or_insert(value: i32, container: &mut Option<i32>) -> &i32 {
169 if container.is_none() {
170 *container = Some(value);
171 }
172
173 container.as_ref().unwrap()
174 }
175
176 let get_or_insert_function = dbg!(DynamicFunction::new(
177 |mut args: ArgList| -> FunctionResult {
178 // The `ArgList` contains the arguments in the order they were pushed.
179 // The `DynamicFunction` will validate that the list contains
180 // exactly the number of arguments we expect.
181 // We can retrieve them out in order (note that this modifies the `ArgList`):
182 let value = args.take::<i32>()?;
183 let container = args.take::<&mut Option<i32>>()?;
184
185 // We could have also done the following to make use of type inference:
186 // let value = args.take_owned()?;
187 // let container = args.take_mut()?;
188
189 Ok(Return::Ref(get_or_insert(value, container)))
190 },
191 // Functions can be either anonymous or named.
192 // It's good practice, though, to try and name your functions whenever possible.
193 // This makes it easier to debug and is also required for function registration.
194 // We can either give it a custom name or use the function's type name as
195 // derived from `std::any::type_name_of_val`.
196 SignatureInfo::named(std::any::type_name_of_val(&get_or_insert))
197 // We can always change the name if needed.
198 // It's a good idea to also ensure that the name is unique,
199 // such as by using its type name or by prefixing it with your crate name.
200 .with_name("my_crate::get_or_insert")
201 // Since our function takes arguments, we should provide that argument information.
202 // This is used to validate arguments when calling the function.
203 // And it aids consumers of the function with their own validation and debugging.
204 // Arguments should be provided in the order they are defined in the function.
205 .with_arg::<i32>("value")
206 .with_arg::<&mut Option<i32>>("container")
207 // We can provide return information as well.
208 .with_return::<&i32>(),
209 ));
210
211 let mut container: Option<i32> = None;
212
213 let args = dbg!(ArgList::new().with_owned(5_i32).with_mut(&mut container));
214 let value = dbg!(get_or_insert_function.call(args).unwrap()).unwrap_ref();
215 assert_eq!(value.try_downcast_ref::<i32>(), Some(&5));
216
217 let args = dbg!(ArgList::new().with_owned(500_i32).with_mut(&mut container));
218 let value = dbg!(get_or_insert_function.call(args).unwrap()).unwrap_ref();
219 assert_eq!(value.try_downcast_ref::<i32>(), Some(&5));
220}
Sourcepub fn info(&self) -> &FunctionInfo
pub fn info(&self) -> &FunctionInfo
Returns the function info.
Sourcepub fn name(&self) -> Option<&Cow<'static, str>>
pub fn name(&self) -> Option<&Cow<'static, str>>
The name of the function.
For DynamicFunctionMuts
created using IntoFunctionMut
,
the default name will always be the full path to the function as returned by core::any::type_name
,
unless the function is a closure, anonymous function, or function pointer,
in which case the name will be None
.
This can be overridden using with_name
.
Sourcepub fn is_overloaded(&self) -> bool
pub fn is_overloaded(&self) -> bool
Returns true
if the function is overloaded.
§Example
let mut total_i32 = 0;
let increment = (|value: i32| total_i32 += value).into_function_mut();
assert!(!increment.is_overloaded());
let mut total_f32 = 0.0;
let increment = increment.with_overload(|value: f32| total_f32 += value);
assert!(increment.is_overloaded());
Sourcepub fn arg_count(&self) -> ArgCount
pub fn arg_count(&self) -> ArgCount
Returns the number of arguments the function expects.
For overloaded functions that can have a variable number of arguments, this will contain the full set of counts for all signatures.
§Example
let add = (|a: i32, b: i32| a + b).into_function_mut();
assert!(add.arg_count().contains(2));
let add = add.with_overload(|a: f32, b: f32, c: f32| a + b + c);
assert!(add.arg_count().contains(2));
assert!(add.arg_count().contains(3));
Trait Implementations§
Source§impl<'env> Debug for DynamicFunctionMut<'env>
Outputs the function’s signature.
impl<'env> Debug for DynamicFunctionMut<'env>
Outputs the function’s signature.
This takes the format: DynamicFunctionMut(fn {name}({arg1}: {type1}, {arg2}: {type2}, ...) -> {return_type})
.
Names for arguments and the function itself are optional and will default to _
if not provided.
If the function is overloaded, the output will include the signatures of all overloads as a set.
For example, DynamicFunctionMut(fn add{(_: i32, _: i32) -> i32, (_: f32, _: f32) -> f32})
.
Source§impl<'env> From<DynamicFunction<'env>> for DynamicFunctionMut<'env>
impl<'env> From<DynamicFunction<'env>> for DynamicFunctionMut<'env>
Source§fn from(function: DynamicFunction<'env>) -> DynamicFunctionMut<'env>
fn from(function: DynamicFunction<'env>) -> DynamicFunctionMut<'env>
Source§impl<'env> IntoFunctionMut<'env, ()> for DynamicFunctionMut<'env>
impl<'env> IntoFunctionMut<'env, ()> for DynamicFunctionMut<'env>
Source§fn into_function_mut(self) -> DynamicFunctionMut<'env>
fn into_function_mut(self) -> DynamicFunctionMut<'env>
Self
into a DynamicFunctionMut
.Auto Trait Implementations§
impl<'env> Freeze for DynamicFunctionMut<'env>
impl<'env> !RefUnwindSafe for DynamicFunctionMut<'env>
impl<'env> !Send for DynamicFunctionMut<'env>
impl<'env> !Sync for DynamicFunctionMut<'env>
impl<'env> Unpin for DynamicFunctionMut<'env>
impl<'env> !UnwindSafe for DynamicFunctionMut<'env>
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.