Created
October 28, 2014 14:08
-
-
Save chrisdavies/9d9c0aff6229ef1d3eef to your computer and use it in GitHub Desktop.
Rust - lifetime constraint and generic constraint on a struct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::Writer; | |
// This specifies lifetime constraint of 'a | |
// Type W must implement the Writer trait | |
// Type W has the lifetime 'a (the same as the related struct instance) | |
pub struct Foo<'a, W: 'a + Writer> { | |
writer: &'a mut W | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment