use std::fmt::Display;
fn main() {
foo(&FooConfig{
title: "hello".to_string()
});
bar(&BarConfig{
title: "hello"
});
baz(&BazConfig{
title: "hello"
});
qux(&QuxConfig{
title: "hello"
});
}
// FOO
pub struct FooConfig {
pub title: String,
}
pub fn foo(config: &FooConfig) {
println!("foo: {}", config.title)
}
// BAR
pub struct BarConfig<D> {
pub title: D,
}
pub fn bar<D: Display>(config: &BarConfig<D>) {
println!("bar: {}", config.title)
}
// BAZ
struct BazConfig<T: ?Sized = dyn Display> {
pub title: T
}
fn baz(config: &BazConfig) {
println!("baz: {}", &config.title)
}
// QUX
struct QuxConfig<'a> {
pub title: &'a str
}
fn qux(config: &QuxConfig) {
println!("qux: {}", config.title)
}