Skip to content

Instantly share code, notes, and snippets.

Created June 12, 2017 23:43
Show Gist options
  • Save anonymous/5ac481c67e095798da72c3f561b3ebd5 to your computer and use it in GitHub Desktop.
Save anonymous/5ac481c67e095798da72c3f561b3ebd5 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
pub struct MyStruct<'a> {
stuffs: Vec<&'a AnotherStruct>
}
pub struct AnotherStruct {
some_data: DataStruct
}
pub struct DataStruct {
number: i32,
another_number: i32,
yet_another_number: i32,
is_cool: bool
}
impl<'a> MyStruct<'a> {
pub fn do_something(&self, data: DataStruct) {
for stuff in &self.stuffs {
if stuff.some_data.is_cool == data.is_cool{
stuff.some_data = data;
break;
}
}
}
}
fn main(){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment