Skip to content

Commit

Permalink
Tidy associated type names
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Jan 17, 2025
1 parent cde6214 commit a91dae4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
24 changes: 12 additions & 12 deletions trace-to-events/src/pulse_detection/datatype/tracepoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ use super::{eventdata::Empty, EventData, Temporal, TraceValue};
pub(crate) trait TracePoint: Clone {
/// The type which represents the time of the data point.
/// This should be trivially copyable (usually a scalar).
type TimeType: Temporal;
type Time: Temporal;

/// The type which contains the value of the data point.
type ValueType: TraceValue;
type Value: TraceValue;

type DataType: EventData;
type Data: EventData;

/// Returns the time of the data point.
fn get_time(&self) -> Self::TimeType;
fn get_time(&self) -> Self::Time;

/// Returns an immutable reference to the value of the data point.
fn get_value(&self) -> &Self::ValueType;
fn get_value(&self) -> &Self::Value;

/// Take ownership of a clone of the value without destructing the data point.
fn clone_value(&self) -> Self::ValueType {
fn clone_value(&self) -> Self::Value {
self.get_value().clone()
}
}
Expand All @@ -35,19 +35,19 @@ where
X: Temporal,
Y: TraceValue,
{
type TimeType = X;
type ValueType = Y;
type DataType = Empty;
type Time = X;
type Value = Y;
type Data = Empty;

fn get_time(&self) -> Self::TimeType {
fn get_time(&self) -> Self::Time {
self.0
}

fn get_value(&self) -> &Self::ValueType {
fn get_value(&self) -> &Self::Value {
&self.1
}

fn clone_value(&self) -> Self::ValueType {
fn clone_value(&self) -> Self::Value {
self.get_value().clone()
}
}
6 changes: 3 additions & 3 deletions trace-to-events/src/pulse_detection/detectors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use super::{pulse::TimeValue, EventData, EventPoint, Pulse, Real, RealArray, Tra

pub(crate) trait Detector: Default + Clone {
type TracePointType: TracePoint;
type EventPointType: EventPoint<TimeType = <Self::TracePointType as TracePoint>::TimeType>;
type EventPointType: EventPoint<TimeType = <Self::TracePointType as TracePoint>::Time>;

fn signal(
&mut self,
time: <Self::TracePointType as TracePoint>::TimeType,
value: <Self::TracePointType as TracePoint>::ValueType,
time: <Self::TracePointType as TracePoint>::Time,
value: <Self::TracePointType as TracePoint>::Value,
) -> Option<Self::EventPointType>;

fn finish(&mut self) -> Option<Self::EventPointType>;
Expand Down
5 changes: 1 addition & 4 deletions trace-to-events/src/pulse_detection/window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ impl<I, W> Iterator for WindowIter<I, W>
where
I: Iterator,
I::Item: TracePoint,
W: Window<
TimeType = <I::Item as TracePoint>::TimeType,
InputType = <I::Item as TracePoint>::ValueType,
>,
W: Window<TimeType = <I::Item as TracePoint>::Time, InputType = <I::Item as TracePoint>::Value>,
{
type Item = (W::TimeType, W::OutputType);

Expand Down

0 comments on commit a91dae4

Please sign in to comment.