-
Rust용어_impl Trait for returning complex type with ease.코딩Coding/Rust용어 2020. 9. 20. 11:49728x90
impl Trait for returning complex types with ease - The Edition Guide
impl Trait is the new way to specify unnamed but concrete types that implement a specific trait. There are two places you can put it: argument position, and return position. trait Trait {} // argument position fn foo(arg: impl Trait) { } // return position
doc.rust-lang.org
Ex)
https://doc.rust-lang.org/rust-by-example/trait/impl_trait.htmlimpl Trait - Rust By Example
If your function returns a type that implements MyTrait, you can write its return type as -> impl MyTrait. This can help simplify your type signatures quite a lot! use std::iter; use std::vec::IntoIter; // This function combines two `Vec ` and returns an i
doc.rust-lang.org
반응형'코딩Coding > Rust용어' 카테고리의 다른 글
Bear-Metal Server(베어 메탈 서버)란? (0) 2021.05.07 Rust용어)연관 함수(Associated function) (0) 2020.10.03 binding(바인딩) (0) 2020.10.03 Rust용어_New module system/Module / Crate (0) 2020.09.20 Rust용어_dyn Trait for trait objects- The Edition Guide (0) 2020.09.20 Rust용어)Non-lexical lifetimes (0) 2020.09.20 Rust용어)Default match binding (0) 2020.09.20 (Rust용어) inference 추론처리 (0) 2020.09.20