ํธ๋ ์(Trait)
ํธ๋ ์์ ํ์ ์ ์ถ์ํ ํ๋๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ์ธํฐํ์ด์ค์ ๋น์ทํฉ๋๋ค:
trait Pet { /// Return a sentence from this pet. fn talk(&self) -> String; /// Print a string to the terminal greeting this pet. fn greet(&self); }
This slide and its sub-slides should take about 15 minutes.
-
ํธ๋ ์์ ํด๋น ํธ๋ ์์ ๊ตฌํํ๊ธฐ ์ํด ํ์ ์ด ๊ฐ์ ธ์ผ ํ๋ ์ฌ๋ฌ ๋ฉ์๋๋ฅผ ์ ์ํฉ๋๋ค.
-
In the โGenericsโ segment, next, we will see how to build functionality that is generic over all types implementing a trait.