Created
May 21, 2014 18:09
-
-
Save SiegeLord/3ab88416b4504ece7d96 to your computer and use it in GitHub Desktop.
Borrowcheck woes
This file contains hidden or 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
test3.rs:106:63: 106:71 error: lifetime of `comp_set` is too short to guarantee its contents can be safely reborrowed | |
test3.rs:106 self.get_comp_idx(Component::get_type(None::<T>)).map(|idx| comp_set.get_mut(idx)) | |
^~~~~~~~ | |
test3.rs:105:2: 115:3 note: `comp_set` would have to be valid for the lifetime &'l as defined on the block at 105:1... | |
test3.rs:105 { | |
test3.rs:106 self.get_comp_idx(Component::get_type(None::<T>)).map(|idx| comp_set.get_mut(idx)) | |
test3.rs:107 | |
test3.rs:108 /* | |
test3.rs:109 match self.get_comp_idx(Component::get_type(None::<T>)) | |
test3.rs:110 { | |
... | |
test3.rs:106:3: 106:85 note: ...but `comp_set` is only valid for the method call at 106:2 | |
test3.rs:106 self.get_comp_idx(Component::get_type(None::<T>)).map(|idx| comp_set.get_mut(idx)) | |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
error: aborting due to previous error |
This file contains hidden or 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
// The ComponentSet get_mut looks like this | |
fn get_mut<'l>(&'l mut self, comp_idx: uint) -> &'l mut T {} | |
fn get_mut<'l, T: Component>(&self, comp_set: &'l mut ComponentSet<T>) -> Option<&'l mut T> | |
{ | |
self.get_comp_idx(Component::get_type(None::<T>)).map(|idx| comp_set.get_mut(idx)) | |
/* | |
match self.get_comp_idx(Component::get_type(None::<T>)) | |
{ | |
Some(idx) => Some(comp_set.get_mut(idx)), | |
None => None | |
} | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment