mirror of
https://github.com/microsoft/RustTraining.git
synced 2026-05-06 06:06:43 -04:00
fix(rust-patterns-book): fix ownership move in HFT Rust example
This commit is contained in:
@@ -438,9 +438,12 @@ struct HighFrequencyTrader {
|
||||
|
||||
impl HighFrequencyTrader {
|
||||
fn process_market_data(&mut self, tick: MarketTick) {
|
||||
// Extract Copy field before moving `tick` into analysis
|
||||
let price = tick.price;
|
||||
|
||||
// Zero allocations, predictable performance
|
||||
let analysis = MarketAnalysis::from(tick);
|
||||
self.trades.push(Trade::new(analysis.signal(), tick.price));
|
||||
self.trades.push(Trade::new(analysis.signal(), price));
|
||||
|
||||
// No GC pauses, consistent sub-microsecond latency
|
||||
// Performance guaranteed by type system
|
||||
|
||||
Reference in New Issue
Block a user