Skip to content

Commit 2905089

Browse files
committed
Add a definition of trait.
This is from the first edition of the book.
1 parent 21928bd commit 2905089

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/glossory.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,11 @@ A string slice is the most primitive string type in Rust, written as `str`. It i
102102
often seen in its borrowed forms, either mutable or shared. The shared
103103
string slice type is `&str`, while the mutable string slice type is `&mut str`.
104104

105-
Strings slices are always valid UTF-8.
105+
Strings slices are always valid UTF-8.
106+
107+
### Trait
108+
109+
A trait is a language item that is used for describing the functionalities a type must provide.
110+
It allow a type to make certain promises about its behavior.
111+
112+
Generic functions and generic structs can exploit traits to constrain, or bound, the types they accept.

0 commit comments

Comments
 (0)