futures_test/task/
record_spawner.rs1use futures_core::future::FutureObj;
2use futures_core::task::{Spawn, SpawnError};
3
4#[derive(Debug)]
18pub struct RecordSpawner {
19 spawned: Vec<FutureObj<'static, ()>>,
20}
21
22impl RecordSpawner {
23 pub fn new() -> Self {
25 Self {
26 spawned: Vec::new(),
27 }
28 }
29
30 pub fn spawned(&self) -> &[FutureObj<'static, ()>] {
32 &self.spawned
33 }
34}
35
36impl Spawn for RecordSpawner {
37 fn spawn_obj(
38 &mut self,
39 future: FutureObj<'static, ()>,
40 ) -> Result<(), SpawnError> {
41 self.spawned.push(future);
42 Ok(())
43 }
44}
45
46impl Default for RecordSpawner {
47 fn default() -> Self {
48 Self::new()
49 }
50}