40
submitted 1 week ago* (last edited 1 week ago) by steam_lover@sh.itjust.works to c/rust@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] orclev@lemmy.world 3 points 1 week ago

It's an API, if you add methods to it then the implementations will support that. That is in fact the entire point of a trait.

[-] BB_C@programming.dev 1 points 1 week ago
struct SomeFuture;

impl Future for SomeFuture {
  // ....
}

where are you going to "pin metadata"?

[-] sukhmel@programming.dev 3 points 1 week ago

I think, they mean:

pub trait Future {
  // ....

  fn put_metadata(...);

  fn get_metadata(...);
}

I find it too magical to be necessary, but I can see how it might be useful. This can be achieved with a wrapper, but will then require you to wrap every future, which is not too convenient

[-] devnev@lemmy.dbzer0.com 3 points 1 week ago

Other languages have ended up introducing it out of practical necessity, e.g. Go's contexts, JS execution contexts. Pick your poison, although I expect Rust's general minimal approach will leave it as extra parameters, Go-style.

load more comments (6 replies)
load more comments (6 replies)
load more comments (6 replies)
this post was submitted on 20 Mar 2026
40 points (100.0% liked)

Rust Programming

9208 readers
1 users here now

founded 7 years ago
MODERATORS