Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Traits as in the original Smalltalk research, Rust traits or Haskell type classes are like interfaces, but only when in scope. So until you import a trait, its implementation on various types isn’t visible.

This makes it possible to safely make a new trait and implement it on a built in type (like giving int a method) without the chance of another unrelated use of the type accidentally using what this trait provides.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: