logoalt Hacker News

aerzenyesterday at 7:49 PM2 repliesview on HN

Someone help me, a rust programmer , understand this: is this like having a function be generic over structs with some fields?

Like having `<T: {width: f64, depth: f64}>`?

I have such a hard time understanding the multiple arrows notation of ML family languages.


Replies

maegultoday at 4:50 AM

Hmmm … my beginner’s rust is getting too rusty.

Is this valid rust (it’d be new to me)?!

If not, I’m guessing, from memory, the only way at this in rust is to through traits?

malcolmgreavesyesterday at 8:08 PM

Yes! The idea is that we just care that it’s something with the named & typed fields. It can have more fields, but we’re really setting a lower bound on what we need to exist for our function to work.