Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent usage of derive attribute issue #70

Open
a2xchip opened this issue Mar 28, 2024 · 0 comments
Open

Consistent usage of derive attribute issue #70

a2xchip opened this issue Mar 28, 2024 · 0 comments

Comments

@a2xchip
Copy link

a2xchip commented Mar 28, 2024

The usage of derive attribute is inconsistent now. And should be fixed.

There are two approaches applying attribute.

In some cases it preceded doc blocks:

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
/// Represents the result of a database query
///
/// # Examples
/// ```
/// # async fn f() {
/// # use libsql_kt::Config;
/// let db = libsql_kt::SyncClient::in_memory().unwrap();
/// let rs = db.execute("create table example(num integer, str text)").unwrap();
/// assert_eq!(rs.columns.is_empty(), true);
/// assert_eq!(rs.rows.is_empty(), true);
/// assert_eq!(rs.rows_affected, 0);
/// assert_eq!(rs.last_insert_rowid, None);
/// db.execute("insert into example (num, str) values (0, 'zero')").unwrap();
/// let rs = db.execute("select * from example").unwrap();
/// assert_eq!(rs.columns, ["num", "str"]);
/// assert_eq!(rs.rows.len(), 1)
/// # }
/// ```
pub struct ResultSet {
    /// name of the columns present in this `ResultSet`.
    pub columns: Vec<String>,
    /// One entry per row returned from the database. See [Row] for details.
    pub rows: Vec<Row>,
    /// How many rows were changed by this statement
    pub rows_affected: u64,
    /// the rowid for last insertion. See <https://www.sqlite.org/c3ref/last_insert_rowid.html> for
    /// details
    pub last_insert_rowid: Option<i64>,
}

In other it is applied after doc blocks:

/// A generic client struct, wrapping possible backends.
/// It's a convenience struct which allows implementing connect()
/// with backends being passed as env parameters.
#[derive(Debug)]
pub enum Client {
    #[cfg(feature = "local_backend")]
    Local(crate::local::Client),
    #[cfg(any(
        feature = "reqwest_backend",
        feature = "workers_backend",
        feature = "spin_backend"
    ))]
    Http(crate::http::Client),
    #[cfg(feature = "hrana_backend")]
    Hrana(crate::hrana::Client),
    Default,
}
  1. Team has to choose single approach
  2. Derive attribute usages should be updated in correspondence with the chosen style. (In best case some linting/re-formatting rule applied).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant