pub struct Task<T, M = ()> { /* private fields */ }Expand description
A spawned task.
A Task can be awaited to retrieve the output of its future.
Dropping a Task cancels it, which means its future won’t be polled again. To drop the
Task handle without canceling it, use detach() instead. To cancel a
task gracefully and wait until it is fully destroyed, use the cancel()
method.
Note that canceling a task actually wakes it and reschedules one last time. Then, the executor
can destroy the task by simply dropping its Runnable or by invoking
run().
§Examples
use smol::{future, Executor};
use std::thread;
let ex = Executor::new();
// Spawn a future onto the executor.
let task = ex.spawn(async {
println!("Hello from a task!");
1 + 2
});
// Run an executor thread.
thread::spawn(move || future::block_on(ex.run(future::pending::<()>())));
// Wait for the task's output.
assert_eq!(future::block_on(task), 3);Implementations§
Source§impl<T, M> Task<T, M>
impl<T, M> Task<T, M>
Sourcepub fn detach(self)
pub fn detach(self)
Detaches the task to let it keep running in the background.
§Examples
use smol::{Executor, Timer};
use std::time::Duration;
let ex = Executor::new();
// Spawn a deamon future.
ex.spawn(async {
loop {
println!("I'm a daemon task looping forever.");
Timer::after(Duration::from_secs(1)).await;
}
})
.detach();Examples found in repository?
46fn spawn_tasks(channel: Res<CubeChannel>) {
47 let pool = AsyncComputeTaskPool::get();
48
49 for x in -NUM_CUBES..NUM_CUBES {
50 for z in -NUM_CUBES..NUM_CUBES {
51 let sender = channel.sender.clone();
52 // Spawn a task on the async compute pool
53 pool.spawn(async move {
54 let delay = Duration::from_secs_f32(rand::rng().random_range(2.0..8.0));
55 // Simulate a delay before task completion
56 Delay::new(delay).await;
57 let _ = sender.send(CubeFinished {
58 transform: Transform::from_xyz(x as f32, 0.5, z as f32),
59 });
60 })
61 .detach();
62 }
63 }
64}More examples
38fn perform_save(
39 image_to_save: Res<ImageToSave>,
40 images: Res<Assets<Image>>,
41 asset_server: Res<AssetServer>,
42) {
43 let image = images.get(&image_to_save.0).unwrap();
44
45 let image = image.clone();
46 let asset_server = asset_server.clone();
47 IoTaskPool::get()
48 .spawn(async move {
49 match save_using_saver(
50 asset_server.clone(),
51 &ImageSaver,
52 &ASSET_PATH.into(),
53 SavedAsset::from_asset(&image),
54 &ImageSaverSettings::default(),
55 )
56 .await
57 {
58 Ok(()) => info!("Completed save of {ASSET_PATH}"),
59 Err(err) => error!("Failed to save asset: {err}"),
60 }
61 })
62 .detach();
63}144fn setup_assets(mut commands: Commands, asset_server: Res<AssetServer>) {
145 let (barrier, guard) = AssetBarrier::new();
146 commands.insert_resource(OneHundredThings(std::array::from_fn(|i| {
147 let builder = asset_server.load_builder().with_guard(guard.clone());
148 match i % 5 {
149 0 => builder.load("models/GolfBall/GolfBall.glb"),
150 1 => builder.load("models/AlienCake/alien.glb"),
151 2 => builder.load("models/AlienCake/cakeBirthday.glb"),
152 3 => builder.load("models/FlightHelmet/FlightHelmet.gltf"),
153 4 => builder.load("models/torus/torus.gltf"),
154 _ => unreachable!(),
155 }
156 })));
157 let future = barrier.wait_async();
158 commands.insert_resource(barrier);
159
160 let loading_state = Arc::new(AtomicBool::new(false));
161 commands.insert_resource(AsyncLoadingState(loading_state.clone()));
162
163 // await the `AssetBarrierFuture`.
164 AsyncComputeTaskPool::get()
165 .spawn(async move {
166 future.await;
167 // Notify via `AsyncLoadingState`
168 loading_state.store(true, Ordering::Release);
169 })
170 .detach();
171}46fn perform_save(boxes: Query<(&Sprite, &Transform), With<Box>>, asset_server: Res<AssetServer>) {
47 // First we extract all the data needed to produce an asset we can save.
48 let boxes = boxes
49 .iter()
50 .map(|(sprite, transform)| OneBox {
51 position: transform.translation.xy(),
52 color: sprite.color,
53 })
54 .collect::<Vec<_>>();
55
56 let asset_server = asset_server.clone();
57 IoTaskPool::get()
58 .spawn(async move {
59 // Build a `SavedAsset` instance from the boxes we extracted.
60 let mut builder = SavedAssetBuilder::new(asset_server.clone(), ASSET_PATH.into());
61 let mut many_boxes = ManyBoxes { boxes: vec![] };
62 for (index, one_box) in boxes.iter().enumerate() {
63 many_boxes
64 .boxes
65 .push(builder.add_labeled_asset_with_new_handle(
66 index.to_string(),
67 SavedAsset::from_asset(one_box),
68 ));
69 }
70
71 let saved_asset = builder.build(&many_boxes);
72 // Save the asset using the provided saver.
73 match save_using_saver(
74 asset_server.clone(),
75 &ManyBoxesSaver,
76 &ASSET_PATH.into(),
77 saved_asset,
78 &(),
79 )
80 .await
81 {
82 Ok(()) => info!("Completed save of {ASSET_PATH}"),
83 Err(err) => error!("Failed to save asset: {err}"),
84 }
85 })
86 .detach();
87}151fn setup_assets_programmatically(
152 commands: &mut Commands,
153 asset_server: &mut AssetServer,
154 animation_graphs: &mut Assets<AnimationGraph>,
155 _save: bool,
156) {
157 // Create the nodes.
158 let mut animation_graph = AnimationGraph::new();
159 let blend_node = animation_graph.add_blend(0.5, animation_graph.root);
160 animation_graph.add_clip(
161 asset_server.load(GltfAssetLabel::Animation(0).from_asset("models/animated/Fox.glb")),
162 1.0,
163 animation_graph.root,
164 );
165 animation_graph.add_clip(
166 asset_server.load(GltfAssetLabel::Animation(1).from_asset("models/animated/Fox.glb")),
167 1.0,
168 blend_node,
169 );
170 animation_graph.add_clip(
171 asset_server.load(GltfAssetLabel::Animation(2).from_asset("models/animated/Fox.glb")),
172 1.0,
173 blend_node,
174 );
175
176 // If asked to save, do so.
177 #[cfg(not(target_arch = "wasm32"))]
178 if _save {
179 let animation_graph = animation_graph.clone();
180
181 IoTaskPool::get()
182 .spawn(async move {
183 use std::io::Write;
184
185 let animation_graph: SerializedAnimationGraph = animation_graph
186 .try_into()
187 .expect("The animation graph failed to convert to its serialized form");
188
189 let serialized_graph =
190 ron::ser::to_string_pretty(&animation_graph, PrettyConfig::default())
191 .expect("Failed to serialize the animation graph");
192 let mut animation_graph_writer = File::create(Path::join(
193 &FileAssetReader::get_base_path(),
194 Path::join(Path::new("assets"), Path::new(ANIMATION_GRAPH_PATH)),
195 ))
196 .expect("Failed to open the animation graph asset");
197 animation_graph_writer
198 .write_all(serialized_graph.as_bytes())
199 .expect("Failed to write the animation graph");
200 })
201 .detach();
202 }
203
204 // Add the graph.
205 let handle = animation_graphs.add(animation_graph);
206
207 // Save the assets in a resource.
208 commands.insert_resource(ExampleAnimationGraph(handle));
209}166fn save_world_system(world: &mut World) {
167 let asset_server = world.resource::<AssetServer>().clone();
168 // The `TypeRegistry` resource contains information about all registered types (including components).
169 // This is used to construct worlds, so we'll want to ensure that we use the registry from the
170 // main world. To do this, we can simply clone the `AppTypeRegistry` resource.
171 let type_registry = world.resource::<AppTypeRegistry>().clone();
172
173 // Any ECS World can be serialized.
174 // For demonstration purposes, we'll create a new one.
175 let mut scene_world = World::new();
176
177 let mut component_b = ComponentB::from_world(world);
178 component_b.value = "hello".to_string();
179 scene_world.spawn((
180 component_b,
181 ComponentA { x: 1.0, y: 2.0 },
182 Transform::IDENTITY,
183 Name::new("joe"),
184 WorldAssetRoot(asset_server.load("models/FlightHelmet/FlightHelmet.gltf#Scene0")),
185 ));
186 scene_world.spawn(ComponentA { x: 3.0, y: 4.0 });
187 scene_world.insert_resource(ResourceA { score: 1 });
188
189 // With our sample world ready to go, we can now create a DynamicWorld from it.
190 // For simplicity, we will create our scene using DynamicWorld directly, but if
191 // you need more control, you can use DynamicWorldBuilder.
192 let dynamic_world = DynamicWorld::from_world_with(&scene_world, &type_registry.read());
193
194 // Dynamic Worlds can be serialized like this:
195 let type_registry = world.resource::<AppTypeRegistry>();
196 let type_registry = type_registry.read();
197 let serialized_world = dynamic_world.serialize(&type_registry).unwrap();
198
199 // Shows the serialized world in the console
200 info!("{}", serialized_world);
201
202 // Writing the world to a new file. Using a task to avoid calling the filesystem APIs in a system
203 // as they are blocking.
204 //
205 // This can't work in Wasm as there is no filesystem access.
206 #[cfg(not(target_arch = "wasm32"))]
207 IoTaskPool::get()
208 .spawn(async move {
209 // Write the world RON data to file
210 File::create(format!("assets/{NEW_WORLD_FILE_PATH}"))
211 .and_then(|mut file| file.write(serialized_world.as_bytes()))
212 .expect("Error while writing world to file");
213 })
214 .detach();
215}Sourcepub async fn cancel(self) -> Option<T>
pub async fn cancel(self) -> Option<T>
Cancels the task and waits for it to stop running.
Returns the task’s output if it was completed just before it got canceled, or None if
it didn’t complete.
While it’s possible to simply drop the Task to cancel it, this is a cleaner way of
canceling because it also waits for the task to stop running.
§Examples
use smol::{future, Executor, Timer};
use std::thread;
use std::time::Duration;
let ex = Executor::new();
// Spawn a deamon future.
let task = ex.spawn(async {
loop {
println!("Even though I'm in an infinite loop, you can still cancel me!");
Timer::after(Duration::from_secs(1)).await;
}
});
// Run an executor thread.
thread::spawn(move || future::block_on(ex.run(future::pending::<()>())));
future::block_on(async {
Timer::after(Duration::from_secs(3)).await;
task.cancel().await;
});Sourcepub fn fallible(self) -> FallibleTask<T, M> ⓘ
pub fn fallible(self) -> FallibleTask<T, M> ⓘ
Converts this task into a FallibleTask.
Like Task, a fallible task will poll the task’s output until it is
completed or cancelled due to its Runnable being
dropped without being run. Resolves to the task’s output when completed,
or None if it didn’t complete.
§Examples
use smol::{future, Executor};
use std::thread;
let ex = Executor::new();
// Spawn a future onto the executor.
let task = ex.spawn(async {
println!("Hello from a task!");
1 + 2
})
.fallible();
// Run an executor thread.
thread::spawn(move || future::block_on(ex.run(future::pending::<()>())));
// Wait for the task's output.
assert_eq!(future::block_on(task), Some(3));use smol::future;
// Schedule function which drops the runnable without running it.
let schedule = move |runnable| drop(runnable);
// Create a task with the future and the schedule function.
let (runnable, task) = async_task::spawn(async {
println!("Hello from a task!");
1 + 2
}, schedule);
runnable.schedule();
// Wait for the task's output.
assert_eq!(future::block_on(task.fallible()), None);Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if the current task is finished.
Note that in a multithreaded environment, this task can change finish immediately after calling this function.
Trait Implementations§
impl<T, M> RefUnwindSafe for Task<T, M>
std only.impl<T, M> Send for Task<T, M>
impl<T, M> Sync for Task<T, M>
impl<T, M> Unpin for Task<T, M>
impl<T, M> UnwindSafe for Task<T, M>
std only.Auto Trait Implementations§
Blanket Implementations§
Source§impl<F> AllowFutureExt for Fwhere
F: Future,
impl<F> AllowFutureExt for Fwhere
F: Future,
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<F, T> AssetReaderFuture for F
impl<F, T> AssetReaderFuture for F
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ConditionalSend for Twhere
T: Send,
impl<T> ConditionalSendFuture for Twhere
T: Future + ConditionalSend,
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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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<F> FutureExt for F
impl<F> FutureExt for F
Source§fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
std only.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F> ⓘ
fn map<U, F>(self, f: F) -> Map<Self, F> ⓘ
Source§fn map_into<U>(self) -> MapInto<Self, U> ⓘ
fn map_into<U>(self) -> MapInto<Self, U> ⓘ
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> ⓘ
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F> ⓘ
f. Read moreSource§fn left_future<B>(self) -> Either<Self, B> ⓘ
fn left_future<B>(self) -> Either<Self, B> ⓘ
Source§fn right_future<A>(self) -> Either<A, Self> ⓘ
fn right_future<A>(self) -> Either<A, Self> ⓘ
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self> ⓘ
fn flatten(self) -> Flatten<Self> ⓘ
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self> ⓘwhere
Self: Sized,
fn fuse(self) -> Fuse<Self> ⓘwhere
Self: Sized,
poll will never again be called once it has
completed. This method can be used to turn any Future into a
FusedFuture. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
Source§fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
std only.std, or crate features alloc and spin only.Source§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
alloc only.Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
alloc only.Source§fn unit_error(self) -> UnitError<Self> ⓘwhere
Self: Sized,
fn unit_error(self) -> UnitError<Self> ⓘwhere
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = ()>.Source§fn never_error(self) -> NeverError<Self> ⓘwhere
Self: Sized,
fn never_error(self) -> NeverError<Self> ⓘwhere
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = Never>.Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T> HitDataExtra for T
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
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> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Source§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.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Settings for T
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<F> SpawnIfAsync<AsyncMarker> for F
impl<F> SpawnIfAsync<AsyncMarker> for F
Source§impl<T> SpawnIfAsync<AsyncResultMarker> for T
impl<T> SpawnIfAsync<AsyncResultMarker> for T
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
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.