Skip to content

Commit 5645280

Browse files
committed
Merge pull request #3 from gralpli/patch-1
Remove lifetime annotation from boxed trait object
2 parents edce4a8 + 38adc61 commit 5645280

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

design_pattern-strategy.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![crate_type = "bin"]
22
//! Example of design pattern inspired from Head First Design Patterns
33
//!
4-
//! Tested with rust-1.3.0
4+
//! Tested with rust-1.14.0
55
//!
66
//! @author Eliovir <http://github.com/~eliovir>
77
//!
@@ -32,16 +32,16 @@ impl FlyBehaviour for DoNotFly {
3232
}
3333

3434
// The object has reference to the variation.
35-
struct Duck<'a> {
36-
fly_behaviour: Box<FlyBehaviour + 'a>,
35+
struct Duck {
36+
fly_behaviour: Box<FlyBehaviour>,
3737
}
3838

39-
impl<'a> Duck<'a> {
39+
impl Duck {
4040
// a method calls the funciton in the variation.
4141
fn fly(&self) {
4242
self.fly_behaviour.fly();
4343
}
44-
fn set_fly_behaviour(&mut self, fly_behaviour: Box<FlyBehaviour + 'a>) {
44+
fn set_fly_behaviour(&mut self, fly_behaviour: Box<FlyBehaviour>) {
4545
self.fly_behaviour = fly_behaviour;
4646
}
4747
}

0 commit comments

Comments
 (0)