Repository: diesel-rs/diesel
File: diesel/src/query_builder/upsert/on_conflict_target_decorations.rs (Rust)

Code before:

impl UndecoratedConflictTarget for NoConflictTarget {}
impl<T> UndecoratedConflictTarget for ConflictTarget<T> {}

/// Interface to add information to conflict targets.
/// Designed to be open for further additions to conflict targets like constraints
pub trait DecoratableTarget<P> {
    /// Output type of filter_target operation
    type FilterOutput;
    /// equivalent to filter of FilterDsl but aimed at conflict targets
    fn filter_target(self, predicate: P) -> Self::FilterOutput;
}

#[derive(Debug)]
pub struct DecoratedConflictTarget<T, U> {
    target: T,
    where_clause: U,
}

impl<T, P> DecoratableTarget<P> for T
where
    P: Expression,
    P::SqlType: BoolOrNullableBool,
    T: UndecoratedConflictTarget,
{
    type FilterOutput = DecoratedConflictTarget<T, WhereClause<P>>;
    fn filter_target(self, predicate: P) -> Self::FilterOutput {
        DecoratedConflictTarget {
            target: self,
            where_clause: NoWhereClause.and(predicate),
        }
    }
}

impl<T, U, P> DecoratableTarget<P> for DecoratedConflictTarget<T, U>
where
    P: Expression,
    P::SqlType: BoolOrNullableBool,
    U: WhereAnd<P>,
{
    type FilterOutput = DecoratedConflictTarget<T, <U as WhereAnd<P>>::Output>;
    fn filter_target(self, predicate: P) -> Self::FilterOutput {
        DecoratedConflictTarget {
            target: self.target,
            where_clause: self.where_clause.and(predicate),
        }
    }
}

impl<DB, T, U> QueryFragment<DB> for DecoratedConflictTarget<T, U>
where

Review comment (suggestion):
```suggestion
    type FilterOutput = DecoratedConflictTarget<T, WhereClause<P>>;
    
```

Code after:

impl UndecoratedConflictTarget for NoConflictTarget {}
impl<T> UndecoratedConflictTarget for ConflictTarget<T> {}

/// Interface to add information to conflict targets.
/// Designed to be open for further additions to conflict targets like constraints
pub trait DecoratableTarget<P> {
    /// Output type of filter_target operation
    type FilterOutput;
    /// equivalent to filter of FilterDsl but aimed at conflict targets
    fn filter_target(self, predicate: P) -> Self::FilterOutput;
}

#[derive(Debug)]
pub struct DecoratedConflictTarget<T, U> {
    target: T,
    where_clause: U,
}

impl<T, P> DecoratableTarget<P> for T
where
    P: Expression,
    P::SqlType: BoolOrNullableBool,
    T: UndecoratedConflictTarget,
{
    type FilterOutput = DecoratedConflictTarget<T, WhereClause<P>>;

    fn filter_target(self, predicate: P) -> Self::FilterOutput {
        DecoratedConflictTarget {
            target: self,
            where_clause: NoWhereClause.and(predicate),
        }
    }
}

impl<T, U, P> DecoratableTarget<P> for DecoratedConflictTarget<T, U>
where
    P: Expression,
    P::SqlType: BoolOrNullableBool,
    U: WhereAnd<P>,
{
    type FilterOutput = DecoratedConflictTarget<T, <U as WhereAnd<P>>::Output>;

    fn filter_target(self, predicate: P) -> Self::FilterOutput {
        DecoratedConflictTarget {
            target: self.target,
            where_clause: self.where_clause.and(predicate),
        }
    }
}