this post was submitted on 17 Jun 2025
12 points (100.0% liked)

Rust

7129 readers
8 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 2 years ago
MODERATORS
 

Maybe the question is not well written, but it's because I do not really know what's happening in here. I'm learning Rust, I'm doing pretty good, but this is the second time that stomp with this.

First, I thought that only the Add trait would be enough, but the LSP keep saying me this if I do not add the "restriction", as far as I know.

What I do not get is what <Output = T> is. I know that is using the type T, but why it is assigned to Output?

The first time that I saw something similar was in the Rust book that comes with rustup, just look at the next function signature

Thank you for you help, you are awesome.

you are viewing a single comment's thread
view the rest of the comments
[โ€“] anselmschueler@ieji.de 4 points 2 weeks ago (1 children)

@capuccino An alternative is to not use T: Add<Output = T>, but to replace your usage of T, where it represents the output type, with <T as Add>::Output

[โ€“] capuccino@lemmy.world 2 points 2 weeks ago

I found it in the book. Is in advanced chapters, near the end, dang. Thank you for your time!