Repository: diesel-rs/diesel
File: diesel/src/row.rs (Rust)

Code before:
    ///
    /// If two or more fields in the query have the given name, the result of
    /// this function is undefined.
    fn get<ST, T>(&self, column_name: &str) -> deserialize::Result<T>
    where
        T: FromSql<ST, DB>;
}

impl<'a, R, DB> NamedRow<'a, DB> for R
where
    R: Row<'a, DB>,
    DB: Backend,
{
    fn get<ST, T>(&self, column_name: &str) -> deserialize::Result<T>
    where
        T: FromSql<ST, DB>,
    {
        let field = Row::get(self, column_name)
            .ok_or_else(|| format!("Column `{column_name}` was not present in query"))?;

        T::from_nullable_sql(field.value())
    }
}

/// A row that can be turned into an owned version
pub trait IntoOwnedRow<'a, DB: Backend> {
    /// The owned version of the row
    type OwnedRow: Row<'a, DB> + Send + 'static;

    /// Turn the row into its owned version
    fn into_owned(self) -> Self::OwnedRow;
}

// These traits are not part of the public API
// because:
// * we want to control who can implement `Row` (for `RowSealed`)
// * `PartialRow` is an implementation detail
// * `RowLifetimeHelper` is an internal backward compatibility helper
pub(crate) mod private {
    use super::*;

    /// This trait restricts who can implement `Row`
    #[cfg_attr(
        doc_cfg,
        doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
    )]
    pub trait RowSealed {}

    /// A row type that wraps an inner row
    ///
    /// This type only allows to access fields of the inner row, whose index is

Review comment (suggestion):
I would like to gate that behind the `i-implement-a-third-party-backend-and-opt-into-breaking-changes` feature, as it's not useful for anyone outside of diesel-async/other crates doing really low level stuff.

Also maybe just make this a super trait of `Row`, so

```suggestion
pub trait IntoOwnedRow<'a, DB: Backend>: Row<'a, DB> {
```

Code after:
    ///
    /// If two or more fields in the query have the given name, the result of
    /// this function is undefined.
    fn get<ST, T>(&self, column_name: &str) -> deserialize::Result<T>
    where
        T: FromSql<ST, DB>;
}

impl<'a, R, DB> NamedRow<'a, DB> for R
where
    R: Row<'a, DB>,
    DB: Backend,
{
    fn get<ST, T>(&self, column_name: &str) -> deserialize::Result<T>
    where
        T: FromSql<ST, DB>,
    {
        let field = Row::get(self, column_name)
            .ok_or_else(|| format!("Column `{column_name}` was not present in query"))?;

        T::from_nullable_sql(field.value())
    }
}

/// A row that can be turned into an owned version
#[diesel_derives::__diesel_public_if(
    feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"
)]
pub trait IntoOwnedRow<'a, DB: Backend>: Row<'a, DB> {
    /// The owned version of the row
    type OwnedRow: Row<'a, DB> + Send + 'static;

    /// Turn the row into its owned version
    fn into_owned(self) -> Self::OwnedRow;
}

// These traits are not part of the public API
// because:
// * we want to control who can implement `Row` (for `RowSealed`)
// * `PartialRow` is an implementation detail
// * `RowLifetimeHelper` is an internal backward compatibility helper
pub(crate) mod private {
    use super::*;

    /// This trait restricts who can implement `Row`
    #[cfg_attr(
        doc_cfg,
        doc(cfg(feature = "i-implement-a-third-party-backend-and-opt-into-breaking-changes"))
    )]
    pub trait RowSealed {}