Togglebit
banner
togglebit.io
Togglebit
@togglebit.io
I used to have friends, touch grass and even go outside. Rust has freed me from all these obligations and difficulties in life
November 13, 2025 at 6:28 PM
In short these two are the same:

type T1<'a> = Box<dyn Bar<'a>>;
type T2<'a> = Box<dyn Bar<'a> + 'a>;

So by returning the type alias we are not returning Box<dyn Trait<'a>> but Box<dyn Trait<'a> + 'a>.
November 13, 2025 at 6:24 PM
At an initial glance it seems like both functions should compile, after all the only difference is that we are returning an alias, right?

SPOILER AHEAD:

So why does the function returning an alias work while the other one doesn't?

The answer can be found here:

doc.rust-lang.org/reference/li...
Lifetime elision - The Rust Reference
doc.rust-lang.org
November 13, 2025 at 6:23 PM
Is this some kind of Star Trek reference?
May 4, 2025 at 9:53 AM
Day 2
Working on: Writing notes for Client / Server networking
Number of interruptions: 1
Did you manage the entire time: yes
April 21, 2025 at 7:10 AM
It's when the coding aspect is less fun it becomes a problem (in this case I find it easier to let my self be distracted instead of solving the two difficult problems ahead of me)
But yes, you are right.
April 20, 2025 at 10:53 AM
Seems sensible! I find it's way to easy to let a whole Sunday go down the drain from consuming too much YouTube and such.
April 20, 2025 at 10:37 AM