Implement SQL Script as a newtype tuple struct

This commit is contained in:
Tobie Morgan Hitchcock 2022-05-04 22:40:41 +01:00
parent 1f05b32f93
commit 42fa91c7bd

View file

@ -1,16 +1,22 @@
use crate::sql::error::IResult; use crate::sql::error::IResult;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fmt; use std::fmt;
use std::ops::Deref;
use std::str; use std::str;
#[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)] #[derive(Clone, Debug, Default, Eq, PartialEq, PartialOrd, Serialize, Deserialize)]
pub struct Script { pub struct Script(pub String);
pub value: String,
impl Deref for Script {
type Target = String;
fn deref(&self) -> &Self::Target {
&self.0
}
} }
impl fmt::Display for Script { impl fmt::Display for Script {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "\"{}\"", self.value) write!(f, "\"{}\"", self.0)
} }
} }