#[derive(TableName)]
{
// Attributes available to this derive:
#[table_name]
}
Expand description
The TableName derive macro automatically generates a table_name function
for a struct, returning the value specified in the table_name attribute.
§Syntax
#[derive(TableName)]
#[table_name = "<table_name>"]
pub struct <StructName> { ... }§Attributes
table_name: Specifies the name of the table as a string (e.g.,#[table_name = "users"]).
§Function Signature
The macro generates a const function named table_name() which returns a &'static str containing the table name
§Example Usage
#[derive(TableName)]
#[table_name = "users"]
pub struct User {
pub id: i32,
pub name: String,
pub age: i32,
}
fn main() {
assert_eq!(User::table_name(), "users");
}