this post was submitted on 14 Aug 2024
3 points (80.0% liked)

Rust Lang

709 readers
5 users here now

Rules [Developing]

Observe our code of conduct

Constructive criticism only

No endless relitigation

No low-effort content

No memes or image macros

No NSFW Content

founded 2 years ago
MODERATORS
top 1 comments
sorted by: hot top controversial new old
[–] njaard 1 points 4 months ago

There's this example:

// Instead of writing:
fn higher_ranked<F>(callback: F)
where
    F: Fn(&Arg) -> Pin<Box<dyn Future<Output = ()> + '_>>
{ todo!() }

// Write this:
fn higher_ranked<F: async Fn(&Arg)> { todo!() }
// Or this:
fn higher_ranked<F: AsyncFn(&Arg)> { todo!() }

But it seems that's in error and it should have the parameter:

fn higher_ranked<F: async Fn(&Arg)>(callback: F){ todo!() }