future is actually a statemachine, and all of the value that kept across the wait point are saved in the statemachine

    for example

    1. async fn foo() -> u32 {
    2. let mut b = [0;1024]
    3. tokio::fs::read_into_string("file", &b).await;
    4. println!("len is {}", b.len());
    5. }

    we can think of a future as mutliple chunk of code

    1. enum Statemachine {
    2. Chunk1 {
    3. x:[u8; 1024],
    4. fut: tokio::fs::ReadIntoFuture<'x>,
    5. },
    6. ...yield
    7. Chunk2 {
    8. }
    9. }

    when we reture the future to the caller, we actually return the statemachine to caller, so this 1024 length of bytes are returned to the caller too. if your async function call another async function, you don’nt know how large data the future will container, that will cause lots of memcpy. One way to solve is, if the variable you pass to future is large, you can box it, so memcpy become cheap.