logoalt Hacker News

nicoburnsyesterday at 1:32 PM2 repliesview on HN

Right, but almost all APIs in Rust use something like

    fn foo(bar: impl BarTrait)
and AFAIK it isn't possible to write that in C (though C++ does allow this kind of thing).

Replies

bfrogyesterday at 3:46 PM

C++ you either use templates or classes and virtuals. In either case the caller doesn't get to decide.

show 1 reply
bsaulyesterday at 3:54 PM

how do apis typically manage to actually « use » the « bar » of your example, such as storing it somewhere, without enforcing some kind of constraints ?

show 2 replies