Skip to content

Instantly share code, notes, and snippets.

@nulldatamap
Created November 13, 2014 08:32
Show Gist options
  • Select an option

  • Save nulldatamap/792013f2a1d8fb1bbeb1 to your computer and use it in GitHub Desktop.

Select an option

Save nulldatamap/792013f2a1d8fb1bbeb1 to your computer and use it in GitHub Desktop.
impl MarketData {
pub fn collect( &mut self, market : &mut Market ) {
self.day_count += 1;
self.asset_history.push( market.assets );
self.price_history.push( market.price );
self.holders_history.push( market.holders );
}
}
impl Market {
pub fn next_day( &mut self ) {
self.recalculate_price();
// Can't do that since we've already borrowed self as mutable
self.data.collect( self );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment