RustBrock/Traits.md
2025-01-30 18:10:46 +00:00

14 lines
448 B
Markdown

# Traits
This is used to defined shared behavior
A *trait* defines the fnctionality a particular type has and can share with other tpyes.
Traits are ued to define shared behavior in an abstract way.
We can use *trait bounds* to specifty that a generic type can be any type that has certain behavior
Note: Traits are similar to a feature often called *interfaces* in other languages, but there are some differences in Rust
## Defining a Trait