Monomorphization1
์ ๋๋ฆญ ์ฝ๋๋ ํธ์ถ๋ถ์์ ๋น ์ ๋๋ฆญ ์ฝ๋๋ก ์ ํ๋ฉ๋๋ค:
Generic code is turned into non-generic code based on the call sites:
fn main() { let integer = Some(5); let float = Some(5.0); }
์ ์ฝ๋๋ ์๋์ ๊ฐ์ด ๋์ํฉ๋๋ค.
behaves as if you wrote
enum Option_i32 { Some(i32), None, } enum Option_f64 { Some(f64), None, } fn main() { let integer = Option_i32::Some(5); let float = Option_f64::Some(5.0); }
์ด๊ฒ์ ์ฝ์คํธ๊ฐ ๋ค์ง ์๋ ์ถ์ํ1์ ๋๋ค: ์ถ์ํ ์์ด ์ง์ ์ฝ๋ฉํ ๊ฒ๊ณผ ์ ํํ ๊ฐ์ ๊ฒฐ๊ณผ์ ๋๋ค.
This is a zero-cost abstraction: you get exactly the same result as if you had hand-coded the data structures without the abstraction.
์ญ์ฃผ
1
์ ๋๋ฆญ๊ณผ ๊ฐ์ด ๋ฐํ์ ์ฝ์คํธ ์์ด ์ปดํ์ผ ์ฝ์คํธ๋ง์ผ๋ก ๋์ํ๋ ์ถ์ํ ์ปจ์ ์ ๋๋ค.