Quick actions

cmd+k|ctrl+k

Navigation

Languages

Struct type params

Snippet info

Language

Rust

Visibility

public

Author

petter

Created

2022-09-05T13:22:11.821319Z

Updated

2022-09-06T05:54:23.538632Z

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)
}
INFO