mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-05-15 18:12:43 +00:00
32 lines
561 B
Rust
32 lines
561 B
Rust
// ./src/generics/multi_bounds.md
|
|
|
|
|
|
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 part0() {
|
|
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);
|
|
}
|
|
|
|
pub fn main() {
|
|
part0();
|
|
}
|
|
|