Skip to content

Commit

Permalink
Use len rather than iter (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Feb 27, 2024
1 parent 9b408f8 commit cde98c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rs/canister/impl/src/model/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::borrow::Cow;

#[derive(Serialize, Deserialize)]
pub struct Events {
#[serde(alias = "events_v2", skip, default = "init_events")]
#[serde(skip, default = "init_events")]
events: StableLog<StorableEvent, Memory, Memory>,
}

Expand All @@ -30,7 +30,7 @@ impl Events {

pub fn stats(&self) -> EventsStats {
EventsStats {
latest_event_index: self.events.iter().last().map(|e| e.index),
latest_event_index: self.events.len().checked_sub(1),
}
}
}
Expand Down

0 comments on commit cde98c6

Please sign in to comment.