impl Trait
ํธ๋ ์ดํธ ๋ฐ์ด๋์ ์ ์ฌํ๊ฒ impl
ํธ๋ ์ดํธ ๋ฌธ๋ฒ์ ํจ์์ ์ธ์์ ๋ฐํ๊ฐ์ ์ ์ฉ ๊ฐ๋ฅํฉ๋๋ค:
Similar to trait bounds, an
impl Trait
syntax can be used in function arguments and return values:
use std::fmt::Display; fn get_x(name: impl Display) -> impl Display { format!("Hello {name}") } fn main() { let x = get_x("foo"); println!("{x}"); }
impl
ํธ๋ ์ดํธ๋ ํฐ๋ณดํผ์ฌ๋ฌธ๋ฒ(::<>
)์๋ ์ฌ์ฉํ ์ ์์ต๋๋ค.impl
ํธ๋ ์ดํธ๋ ์ต๋ช ํ์ ๊ณผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
impl Trait
cannot be used with the::<>
turbo fish syntax.impl Trait
allows you to work with types which you cannot name.