Repository: diesel-rs/diesel
File: diesel/src/pg/expression/expression_methods.rs (Rust)

Code before:
    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)").execute(conn).unwrap();
    /// #
    /// diesel::insert_into(posts)
    ///     .values(&vec![
    ///         (versions.eq((Bound::Included(1), Bound::Included(8))))
    ///     ])
    ///     .execute(conn)?;
    ///
    /// let data = posts.select(versions.difference_range((Bound::Included(3),Bound::Included(8))))
    ///     .load::<(Bound<i32>,Bound<i32>)>(conn)?;
    /// let expected_range = (Bound::Included(1),Bound::Excluded(3));
    /// assert_eq!(expected_range, data[0]);
    /// #     Ok(())
    /// # }
    /// ```
    fn difference_range<T>(self, other: T) -> dsl::Difference<Self, T>
    where
        Self::SqlType: SqlType,
        T: AsExpression<Self::SqlType>,
    {
        Grouped(DifferenceRange::new(self, other.as_expression()))
    }

    /// Creates a PostgreSQL ` * ` expression.
    ///
    /// This operator takes two ranges and returns the difference.
    ///
    /// # Example
    ///
    /// ```rust
    /// # include!("../../doctest_setup.rs");
    /// #
    /// # table! {
    /// #     posts {
    /// #         id -> Integer,
    /// #         versions -> Range<Integer>,
    /// #     }
    /// # }
    /// #
    /// # fn main() {
    /// #     run_test().unwrap();
    /// # }
    /// #
    /// # fn run_test() -> QueryResult<()> {
    /// #     use self::posts::dsl::*;
    /// #     use std::collections::Bound;
    /// #     let conn = &mut establish_connection();
    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)").execute(conn).unwrap();
    /// #
    /// diesel::insert_into(posts)

Review comment (suggestion):
```suggestion
    /// This operator takes two ranges and returns the intersection.
```

Code after:
    /// #     use std::collections::Bound;
    /// #     let conn = &mut establish_connection();
    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();
    /// #     diesel::sql_query("CREATE TABLE posts (id SERIAL PRIMARY KEY, versions INT4RANGE NOT NULL)").execute(conn).unwrap();
    /// #
    /// diesel::insert_into(posts)
    ///     .values(&vec![
    ///         (versions.eq((Bound::Included(1), Bound::Included(8))))
    ///     ])
    ///     .execute(conn)?;
    ///
    /// let data = posts.select(versions.difference_range((Bound::Included(3),Bound::Included(8))))
    ///     .load::<(Bound<i32>,Bound<i32>)>(conn)?;
    /// let expected_range = (Bound::Included(1),Bound::Excluded(3));
    /// assert_eq!(expected_range, data[0]);
    /// #     Ok(())
    /// # }
    /// ```
    fn difference_range<T>(self, other: T) -> dsl::Difference<Self, T>
    where
        Self::SqlType: SqlType,
        T: AsExpression<Self::SqlType>,
    {
        Grouped(DifferenceRange::new(self, other.as_expression()))
    }

    /// Creates a PostgreSQL ` * ` expression.
    ///
    /// This operator takes two ranges and returns the intersection.
    ///
    /// # Example
    ///
    /// ```rust
    /// # include!("../../doctest_setup.rs");
    /// #
    /// # table! {
    /// #     posts {
    /// #         id -> Integer,
    /// #         versions -> Range<Integer>,
    /// #     }
    /// # }
    /// #
    /// # fn main() {
    /// #     run_test().unwrap();
    /// # }
    /// #
    /// # fn run_test() -> QueryResult<()> {
    /// #     use self::posts::dsl::*;
    /// #     use std::collections::Bound;
    /// #     let conn = &mut establish_connection();
    /// #     diesel::sql_query("DROP TABLE IF EXISTS posts").execute(conn).unwrap();