blob: 969ba6417eca02c0217ee889a21292a0e1963b95 [file] [log] [blame] [view] [edit]
# Multiple bounds
Multiple bounds for a single type can be applied with a `+`. Like normal, different types are
separated with `,`.
```rust,editable
use std::fmt::{Debug, Display};
fn compare_prints<T: Debug + Display>(t: &T) {
println!("Debug: `{:?}`", t);
println!("Display: `{}`", t);
}
fn compare_types<T: Debug, U: Debug>(t: &T, u: &U) {
println!("t: `{:?}`", t);
println!("u: `{:?}`", u);
}
fn main() {
let string = "words";
let array = [1, 2, 3];
let vec = vec![1, 2, 3];
compare_prints(&string);
//compare_prints(&array);
// TODO ^ Try uncommenting this.
compare_types(&array, &vec);
}
```
### See also:
[`std::fmt`][fmt] and [`trait`s][traits]
[fmt]: ../hello/print.md
[traits]: ../trait.md