Re: [RFC PATCH 1/2] rust: LED abstraction
From: Miguel Ojeda
Date: Mon Nov 18 2024 - 11:39:30 EST
On Mon, Nov 18, 2024 at 11:19 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> wrote:
>
> signature. When you write `impl<T>`, then this means that it is a
> template (we use the word "generic" in Rust rather than "template"),
Marek: a main difference is that generics in Rust require you to spell
out everything your type needs in order to be able to use it in the
implementation, unlike C++ templates which will gladly accept any type
as long as the resulting code compiles (i.e. whether the types make
sense or not).
So in C++ you may typically do just `T`, while in Rust you typically
restrict your types with bounds and `where`s clauses like Alice shows.
I hope that clarifies a bit!
Cheers,
Miguel