logoalt Hacker News

xg15yesterday at 8:53 PM1 replyview on HN

Ah, that makes sense. Rust noob here, so I wasn't aware traits can act on types directly without any instance of the type. Thanks for the info!


Replies

Sharlinyesterday at 9:27 PM

Yep, they can have static methods, as it were (in Rust lingo called "associated functions"; "methods" in Rust always take a `self` receiver). Traits can also have associated types and associated constants, which (naturally) also relate to the type, not any particular instance.