impl Display for ID (#783)
This commit is contained in:
parent
746aff34a5
commit
68210f54ca
1 changed files with 15 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
use std::{char, convert::From, marker::PhantomData, ops::Deref, rc::Rc, thread::JoinHandle, u32};
|
||||
use std::{
|
||||
char, convert::From, fmt, marker::PhantomData, ops::Deref, rc::Rc, thread::JoinHandle, u32,
|
||||
};
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
@ -42,6 +44,12 @@ impl Deref for ID {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ID {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
#[crate::graphql_scalar(name = "ID")]
|
||||
impl<S> GraphQLScalar for ID
|
||||
where
|
||||
|
@ -488,6 +496,12 @@ mod tests {
|
|||
assert_eq!(id.len(), 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_id_display() {
|
||||
let id = ID(String::from("foo"));
|
||||
assert_eq!(format!("{}", id), "foo");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_strings() {
|
||||
fn parse_string(s: &str, expected: &str) {
|
||||
|
|
Loading…
Reference in a new issue