That block defines a new trait called Foo
, which then allows you to use the trait in various places such as the impl
block you have posted. The : Bar
part says that any type that implements Foo
must also implement the Bar
trait.
More Related Contents:
- How to get a reference to a concrete type from a trait object?
- Why can impl trait not be used to return multiple / conditional types?
- How do I implement a trait I don’t own for a type I don’t own?
- What makes something a “trait object”?
- Is it possible to use `impl Trait` as a function’s return type in a trait definition?
- How do I return an instance of a trait from a method?
- I implemented a trait for another trait but cannot call methods from both traits
- Why would I implement methods on a trait instead of as part of the trait?
- How does the mechanism behind the creation of boxed traits work?
- Trait implementation for both a trait object and for direct implementors of the trait
- Why is the `Sized` bound necessary in this trait?
- How can I implement Rust’s Copy trait?
- Is there any trait that specifies numeric functionality?
- Understanding Traits and Object Safety
- How do I pass a closure through raw pointers as an argument to a C function?
- Can’t implement a trait I don’t own for all types that implement a trait I do own
- How do I specify that a struct field must implement a trait?
- Rust equivalent to Swift’s extension methods to a protocol?
- Cannot use moved BufReader after for loop with bufreader.lines()
- Do I have to implement a trait twice when implementing it for both reference and non-reference types?
- How is there a conflicting implementation of `From` when using a generic type?
- How do I read the entire body of a Tokio-based Hyper request?
- When returning the outcome of consuming a StdinLock, why was the borrow to stdin retained?
- How does Rust pattern matching determine if the bound variable will be a reference or a value?
- print! macro not executed until pressing Enter
- Why am I getting “parameter is never used [E0392]”?
- How to create and write to memory mapped files?
- Downcast traits inside Rc for AST manipulation
- How to check in Rust if architecture is 32 or 64 bit?
- Is there any way to restrict a generic type to one of several types?