@@ -4,6 +4,7 @@ use std::collections::HashMap;
44use std:: error;
55use std:: fmt;
66use std:: io:: prelude:: * ;
7+ use std:: sync:: Arc ;
78use byteorder:: { ReadBytesExt , WriteBytesExt , BigEndian } ;
89
910pub use self :: slice:: Slice ;
@@ -128,7 +129,7 @@ macro_rules! make_postgres_type {
128129 $variant,
129130 ) +
130131 /// An unknown type.
131- Other ( Box < Other > ) ,
132+ Other ( Other ) ,
132133 }
133134
134135 impl fmt:: Debug for Type {
@@ -520,8 +521,22 @@ make_postgres_type! {
520521}
521522
522523/// Information about an unknown type.
523- #[ derive( PartialEq , Eq , Clone , Debug ) ]
524- pub struct Other {
524+ #[ derive( PartialEq , Eq , Clone ) ]
525+ pub struct Other ( Arc < OtherInner > ) ;
526+
527+ impl fmt:: Debug for Other {
528+ fn fmt ( & self , fmt : & mut fmt:: Formatter ) -> fmt:: Result {
529+ fmt. debug_struct ( "Other" )
530+ . field ( "name" , & self . 0 . name )
531+ . field ( "oid" , & self . 0 . oid )
532+ . field ( "kind" , & self . 0 . kind )
533+ . field ( "schema" , & self . 0 . schema )
534+ . finish ( )
535+ }
536+ }
537+
538+ #[ derive( PartialEq , Eq ) ]
539+ struct OtherInner {
525540 name : String ,
526541 oid : Oid ,
527542 kind : Kind ,
@@ -530,34 +545,34 @@ pub struct Other {
530545
531546impl OtherNew for Other {
532547 fn new ( name : String , oid : Oid , kind : Kind , schema : String ) -> Other {
533- Other {
548+ Other ( Arc :: new ( OtherInner {
534549 name : name,
535550 oid : oid,
536551 kind : kind,
537552 schema : schema,
538- }
553+ } ) )
539554 }
540555}
541556
542557impl Other {
543558 /// The name of the type.
544559 pub fn name ( & self ) -> & str {
545- & self . name
560+ & self . 0 . name
546561 }
547562
548563 /// The OID of this type.
549564 pub fn oid ( & self ) -> Oid {
550- self . oid
565+ self . 0 . oid
551566 }
552567
553568 /// The kind of this type.
554569 pub fn kind ( & self ) -> & Kind {
555- & self . kind
570+ & self . 0 . kind
556571 }
557572
558573 /// The schema of this type.
559574 pub fn schema ( & self ) -> & str {
560- & self . schema
575+ & self . 0 . schema
561576 }
562577}
563578
0 commit comments