Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
programming:rust [2020/12/13 18:14] – [Traits] mh | programming:rust [2020/12/13 18:21] – [Traits] mh | ||
---|---|---|---|
Line 494: | Line 494: | ||
</ | </ | ||
- | Each type implementing the '' | + | Each type implementing the '' |
+ | |||
+ | To implement a trait on a type : | ||
+ | |||
+ | <code rust> | ||
+ | impl Summary for SomeStruct { | ||
+ | fn summarize(& | ||
+ | //some code | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | If the trait had a default behavior, this implementation will override it. | ||
===== Misc ===== | ===== Misc ===== | ||