toasty_sql/stmt/
ident.rs

1use std::fmt;
2
3/// A SQL identifier (table name, column name, etc.).
4///
5/// Wraps a string-like value. When serialized, the identifier is quoted to
6/// avoid conflicts with SQL reserved words.
7///
8/// # Example
9///
10/// ```
11/// use toasty_sql::stmt::Ident;
12///
13/// let id = Ident::from("users");
14/// assert_eq!(id.to_string(), "users");
15/// ```
16#[derive(Debug, Clone)]
17pub struct Ident<T = String>(pub T);
18
19impl From<&str> for Ident {
20    fn from(value: &str) -> Self {
21        Ident(value.into())
22    }
23}
24
25impl fmt::Display for Ident {
26    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27        self.0.fmt(f)
28    }
29}