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 authored and mehcode committed Apr 16, 2020
1 parent bfc52ca commit 2fb38dd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions sqlx-core/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,29 @@ 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
}
}
}
#[cfg(feature = "json")]
pub use self::json::Json;

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 2fb38dd

Please sign in to comment.