Mastodon Feed: Post

Mastodon Feed

jsonstein@masto.deoan.org ("Jeff Sonstein") wrote:

sigh, I'm going to need stronger drugz to walk my way through this "example":

----- snip -----
use std::fmt::Display;

fn longest_with_an_announcement<'a, T>(
x: &'a str,
y: &'a str,
ann: T,
) -> &'a str
where
T: Display,
{
println!("Announcement! {}", ann);
if x.len() > y.len() {
x
} else {
y
}
}
----- snip -----
#LearningRust