Skip to content

Commit

Permalink
Derive all traits and impl Deref and AsRef for types::Json
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Apr 14, 2020
1 parent c6e9b27 commit ae71db8
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions sqlx-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,27 @@ pub mod ipnetwork {
}

#[cfg(feature = "json")]
#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
#[derive(Debug, PartialEq)]
pub struct Json<T>(pub T);
pub mod json {
use std::ops::Deref;

#[cfg_attr(docsrs, doc(cfg(feature = "json")))]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Json<T>(pub T);

impl<T> Deref for Json<T> {
type Target = T;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl<T> AsRef<T> for Json<T> {
fn as_ref(&self) -> &T {
&self.0
}
}
}

pub trait TypeInfo: PartialEq<Self> + Debug + Display + Clone {
/// Compares type information to determine if `other` is compatible at the Rust level
Expand Down

0 comments on commit ae71db8

Please sign in to comment.