fix: Reduce type complexity
As now caught by clippy. https://rust-lang.github.io/rust-clippy/master/index.html#type_complexitypull/24376/head
parent
3a501a4a10
commit
d8d29bc4b4
|
@ -34,6 +34,8 @@ pub trait ResourceEstimator: Debug + Send + Sync + 'static {
|
|||
fn consumption(&self, k: &Self::K, v: &Self::V) -> Self::S;
|
||||
}
|
||||
|
||||
type BoxedEstimatorFn<K, V, S> = Box<dyn (Fn(&K, &V) -> S) + Send + Sync>;
|
||||
|
||||
/// A simple function-based [`ResourceEstimator].
|
||||
pub struct FunctionEstimator<K, V, S>
|
||||
where
|
||||
|
@ -41,7 +43,7 @@ where
|
|||
V: 'static,
|
||||
S: Resource,
|
||||
{
|
||||
estimator: Box<dyn (Fn(&K, &V) -> S) + Send + Sync>,
|
||||
estimator: BoxedEstimatorFn<K, V, S>,
|
||||
}
|
||||
|
||||
impl<K, V, S> FunctionEstimator<K, V, S>
|
||||
|
|
|
@ -195,6 +195,9 @@ impl SelectorOutput {
|
|||
}
|
||||
|
||||
type ReturnTypeFunction = Arc<dyn Fn(&[DataType]) -> DataFusionResult<Arc<DataType>> + Send + Sync>;
|
||||
type StateTypeFactory =
|
||||
Arc<dyn Fn(&DataType) -> DataFusionResult<Arc<Vec<DataType>>> + Send + Sync>;
|
||||
type Factory = Arc<dyn Fn() -> DataFusionResult<Box<dyn Accumulator>> + Send + Sync>;
|
||||
|
||||
/// Factory function for creating the UDA function for DataFusion
|
||||
fn make_uda<SELECTOR>(name: &'static str, output: SelectorOutput) -> AggregateUDF
|
||||
|
@ -208,11 +211,9 @@ where
|
|||
);
|
||||
|
||||
let state_type = Arc::new(vec![value_data_type.clone(), TIME_DATA_TYPE()]);
|
||||
let state_type_factory: Arc<
|
||||
dyn Fn(&DataType) -> DataFusionResult<Arc<Vec<DataType>>> + Send + Sync,
|
||||
> = Arc::new(move |_| Ok(Arc::clone(&state_type)));
|
||||
let state_type_factory: StateTypeFactory = Arc::new(move |_| Ok(Arc::clone(&state_type)));
|
||||
|
||||
let factory: Arc<dyn Fn() -> DataFusionResult<Box<dyn Accumulator>> + Send + Sync> =
|
||||
let factory: Factory =
|
||||
Arc::new(move || Ok(Box::new(SelectorAccumulator::<SELECTOR>::new(output))));
|
||||
|
||||
let return_type = Arc::new(output.return_type(&value_data_type));
|
||||
|
|
|
@ -66,6 +66,9 @@ impl<'a> StepTestState<'a> {
|
|||
/// ```
|
||||
pub type FCustom = Box<dyn for<'b> FnOnce(&'b mut StepTestState) -> BoxFuture<'b, ()>>;
|
||||
|
||||
/// Function to do custom validation on metrics. Expected to panic on validation failure.
|
||||
pub type MetricsValidationFn = Box<dyn Fn(&mut StepTestState, String)>;
|
||||
|
||||
/// Possible test steps that a test can perform
|
||||
pub enum Step {
|
||||
/// Writes the specified line protocol to the `/api/v2/write`
|
||||
|
@ -115,7 +118,7 @@ pub enum Step {
|
|||
///
|
||||
/// The validation function is expected to panic on validation
|
||||
/// failure.
|
||||
VerifiedMetrics(Box<dyn Fn(&mut StepTestState, String)>),
|
||||
VerifiedMetrics(MetricsValidationFn),
|
||||
|
||||
/// A custom step that can be used to implement special cases that
|
||||
/// are only used once.
|
||||
|
|
Loading…
Reference in New Issue