menu
techminis

A naukri.com initiative

google-web-stories
Home

>

Programming News

>

Returning ...
source image

Medium

1w

read

132

img
dot

Image Credit: Medium

Returning Traits in Rust: Powerful, But With a Catch

  • To return traits in Rust, the return values must resolve to the same concrete type.
  • Returning a trait object of type `dyn Animal` requires using a pointer type like `Box`.
  • Even if multiple types implement the same trait, they cannot be returned directly without boxing.
  • The use of `impl Trait` requires returning a single, specific concrete type that implements the trait.

Read Full Article

like

7 Likes

For uninterrupted reading, download the app