1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT license.
*/
////////////////
// SendFuture //
////////////////
/// A simplified type alias for `Future<Output = T> + Send`.
///////////////////
// AsyncFriendly //
///////////////////
/// The bounds `Send + Sync + 'static` are often required by type parameters to make Futures
/// `Send + Sync + 'static`.
///
/// This trait bundles these into a single super-trait for convenience.
////////////////
// AssertSend //
////////////////
/// If your future is not `Send` enough, try this.
///
/// Async functions (i.e., those with the keyword async) rely on type inference to
/// automatically derive `Send` and `Sync` bounds for the returned `Future`s. Unfortunately,
/// `rustc` seems to throw away quite a bit of information when building large futures like
/// we have in `diskann_async`, which can result in large futures failing to be `Send`
/// due to the bound on an inner `Future` being forgotten.
///
/// The [`AssertSend`] is a hack that helps `rustc` realize that interior `Future`s are
/// indeed `Send` and helps when proving the auto trait for larger `Future`s.
///
/// This is mainly helpful when async functions take closures.
///////////
// boxit //
///////////
/// Type erase the provided future by boxing it.
///
/// THis can potentially help with compilation time and future size bloat by factoring out
/// pieces of larger futures into opaque chunks.