From d24b82893244b3e0f956136864ea472652b13f83 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 10 Jul 2014 10:18:23 -0400 Subject: [PATCH] syntax::ast: Derive lots of Show impls --- src/libsyntax/ast.rs | 136 +++++++++++++++++------------------ src/libsyntax/owned_slice.rs | 12 ++++ 2 files changed, 80 insertions(+), 68 deletions(-) diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 9d5038467032d..f32a6b3534d6f 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -145,7 +145,7 @@ impl, E> Decodable for Ident { /// Function name (not all functions have names) pub type FnIdent = Option; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Lifetime { pub id: NodeId, pub span: Span, @@ -155,7 +155,7 @@ pub struct Lifetime { /// A "Path" is essentially Rust's notion of a name; for instance: /// std::cmp::PartialEq . It's represented as a sequence of identifiers, /// along with a bunch of supporting information. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Path { pub span: Span, /// A `::foo` path, is relative to the crate root rather than current @@ -167,7 +167,7 @@ pub struct Path { /// A segment of a path: an identifier, an optional lifetime, and a set of /// types. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct PathSegment { /// The identifier portion of this path segment. pub identifier: Ident, @@ -201,7 +201,7 @@ pub static DUMMY_NODE_ID: NodeId = -1; /// typeck::collect::compute_bounds matches these against /// the "special" built-in traits (see middle::lang_items) and /// detects Copy, Send and Share. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum TyParamBound { TraitTyParamBound(TraitRef), StaticRegionTyParamBound, @@ -209,7 +209,7 @@ pub enum TyParamBound { OtherRegionTyParamBound(Span) // FIXME -- just here until work for #5723 lands } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct TyParam { pub ident: Ident, pub id: NodeId, @@ -221,7 +221,7 @@ pub struct TyParam { /// Represents lifetimes and type parameters attached to a declaration /// of a function, enum, trait, etc. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Generics { pub lifetimes: Vec, pub ty_params: OwnedSlice, @@ -243,7 +243,7 @@ impl Generics { /// used to drive conditional compilation pub type CrateConfig = Vec> ; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Crate { pub module: Mod, pub attrs: Vec, @@ -253,7 +253,7 @@ pub struct Crate { pub type MetaItem = Spanned; -#[deriving(Clone, Encodable, Decodable, Eq, Hash)] +#[deriving(Clone, Encodable, Decodable, Eq, Hash, Show)] pub enum MetaItem_ { MetaWord(InternedString), MetaList(InternedString, Vec>), @@ -285,7 +285,7 @@ impl PartialEq for MetaItem_ { } } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Block { pub view_items: Vec, pub stmts: Vec>, @@ -295,26 +295,26 @@ pub struct Block { pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Pat { pub id: NodeId, pub node: Pat_, pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct FieldPat { pub ident: Ident, pub pat: Gc, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum BindingMode { BindByRef(Mutability), BindByValue(Mutability), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Pat_ { PatWild, PatWildMulti, @@ -346,7 +346,7 @@ pub enum Mutability { MutImmutable, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum ExprVstore { /// ~[1, 2, 3, 4] ExprVstoreUniq, @@ -356,7 +356,7 @@ pub enum ExprVstore { ExprVstoreMutSlice, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum BinOp { BiAdd, BiSub, @@ -378,7 +378,7 @@ pub enum BinOp { BiGt, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum UnOp { UnBox, UnUniq, @@ -389,7 +389,7 @@ pub enum UnOp { pub type Stmt = Spanned; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Stmt_ { /// Could be an item or a local (let) binding: StmtDecl(Gc, NodeId), @@ -406,7 +406,7 @@ pub enum Stmt_ { /// Where a local declaration came from: either a true `let ... = /// ...;`, or one desugared from the pattern of a for loop. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum LocalSource { LocalLet, LocalFor, @@ -415,7 +415,7 @@ pub enum LocalSource { // FIXME (pending discussion of #1697, #2178...): local should really be // a refinement on pat. /// Local represents a `let` statement, e.g., `let : = ;` -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Local { pub ty: P, pub pat: Gc, @@ -427,7 +427,7 @@ pub struct Local { pub type Decl = Spanned; -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Decl_ { /// A local (let) binding: DeclLocal(Gc), @@ -436,7 +436,7 @@ pub enum Decl_ { } /// represents one arm of a 'match' -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Arm { pub attrs: Vec, pub pats: Vec>, @@ -444,7 +444,7 @@ pub struct Arm { pub body: Gc, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Field { pub ident: SpannedIdent, pub expr: Gc, @@ -453,26 +453,26 @@ pub struct Field { pub type SpannedIdent = Spanned; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum BlockCheckMode { DefaultBlock, UnsafeBlock(UnsafeSource), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum UnsafeSource { CompilerGenerated, UserProvided, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Expr { pub id: NodeId, pub node: Expr_, pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Expr_ { ExprVstore(Gc, ExprVstore), /// First expr is the place; second expr is the value. @@ -539,7 +539,7 @@ pub enum Expr_ { /// makes any real sense. You could write them elsewhere but nothing /// else knows what to do with them, so you'll probably get a syntax /// error. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] #[doc="For macro invocations; parsing is delegated to the macro"] pub enum TokenTree { /// A single token @@ -613,7 +613,7 @@ pub enum TokenTree { /// macro system. Congratulations. pub type Matcher = Spanned; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Matcher_ { /// Match one token MatchTok(::parse::token::Token), @@ -630,7 +630,7 @@ pub type Mac = Spanned; /// is being invoked, and the vector of token-trees contains the source /// of the macro invocation. /// There's only one flavor, now, so this could presumably be simplified. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Mac_ { MacInvocTT(Path, Vec , SyntaxContext), // new macro-invocation } @@ -660,13 +660,13 @@ pub enum Lit_ { // NB: If you change this, you'll probably want to change the corresponding // type structure in middle/ty.rs as well. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct MutTy { pub ty: P, pub mutbl: Mutability, } -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct TypeField { pub ident: Ident, pub mt: MutTy, @@ -675,7 +675,7 @@ pub struct TypeField { /// Represents a required method in a trait declaration, /// one without a default implementation -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct TypeMethod { pub ident: Ident, pub attrs: Vec, @@ -692,7 +692,7 @@ pub struct TypeMethod { /// a default implementation A trait method is either required (meaning it /// doesn't have an implementation, just a signature) or provided (meaning it /// has a default implementation). -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum TraitMethod { Required(TypeMethod), Provided(Gc), @@ -769,7 +769,7 @@ impl FloatTy { } // NB PartialEq method appears below. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Ty { pub id: NodeId, pub node: Ty_, @@ -777,7 +777,7 @@ pub struct Ty { } /// Not represented directly in the AST, referred to by name through a ty_path. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum PrimTy { TyInt(IntTy), TyUint(UintTy), @@ -803,7 +803,7 @@ impl fmt::Show for Onceness { } /// Represents the type of a closure -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct ClosureTy { pub lifetimes: Vec, pub fn_style: FnStyle, @@ -816,7 +816,7 @@ pub struct ClosureTy { pub bounds: Option>, } -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct BareFnTy { pub fn_style: FnStyle, pub abi: Abi, @@ -824,12 +824,12 @@ pub struct BareFnTy { pub decl: P } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct UnboxedFnTy { pub decl: P, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Ty_ { TyNil, TyBot, /* bottom type */ @@ -853,13 +853,13 @@ pub enum Ty_ { TyInfer, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum AsmDialect { AsmAtt, AsmIntel } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct InlineAsm { pub asm: InternedString, pub asm_str_style: StrStyle, @@ -872,7 +872,7 @@ pub struct InlineAsm { } /// represents an argument in a function header -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Arg { pub ty: P, pub pat: Gc, @@ -900,7 +900,7 @@ impl Arg { } /// represents the header (not the body) of a function declaration -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct FnDecl { pub inputs: Vec, pub output: P, @@ -925,7 +925,7 @@ impl fmt::Show for FnStyle { } } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum RetStyle { /// Functions with return type ! that always /// raise an error or exit (i.e. never return to the caller) @@ -935,7 +935,7 @@ pub enum RetStyle { } /// Represents the kind of 'self' associated with a method -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum ExplicitSelf_ { /// No self SelfStatic, @@ -950,7 +950,7 @@ pub enum ExplicitSelf_ { pub type ExplicitSelf = Spanned; // Represents a method declaration -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Method { pub ident: Ident, pub attrs: Vec, @@ -964,7 +964,7 @@ pub struct Method { pub vis: Visibility, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Mod { /// A span from the first token past `{` to the last token until `}`. /// For `mod foo;`, the inner span ranges from the first token @@ -974,31 +974,31 @@ pub struct Mod { pub items: Vec>, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct ForeignMod { pub abi: Abi, pub view_items: Vec, pub items: Vec>, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct VariantArg { pub ty: P, pub id: NodeId, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum VariantKind { TupleVariantKind(Vec), StructVariantKind(Gc), } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct EnumDef { pub variants: Vec>, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Variant_ { pub name: Ident, pub attrs: Vec, @@ -1010,7 +1010,7 @@ pub struct Variant_ { pub type Variant = Spanned; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct PathListIdent_ { pub name: Ident, pub id: NodeId, @@ -1020,7 +1020,7 @@ pub type PathListIdent = Spanned; pub type ViewPath = Spanned; -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum ViewPath_ { /// `quux = foo::bar::baz` @@ -1037,7 +1037,7 @@ pub enum ViewPath_ { ViewPathList(Path, Vec , NodeId) } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct ViewItem { pub node: ViewItem_, pub attrs: Vec, @@ -1045,7 +1045,7 @@ pub struct ViewItem { pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum ViewItem_ { /// Ident: name used to refer to this crate in the code /// optional (InternedString,StrStyle): if present, this is a location @@ -1061,17 +1061,17 @@ pub type Attribute = Spanned; /// Distinguishes between Attributes that decorate items and Attributes that /// are contained as statements within items. These two cases need to be /// distinguished for pretty-printing. -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum AttrStyle { AttrOuter, AttrInner, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct AttrId(pub uint); /// Doc-comments are promoted to attributes that have is_sugared_doc = true -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Attribute_ { pub id: AttrId, pub style: AttrStyle, @@ -1085,7 +1085,7 @@ pub struct Attribute_ { /// that the ref_id is for. The impl_id maps to the "self type" of this impl. /// If this impl is an ItemImpl, the impl_id is redundant (it could be the /// same as the impl's node id). -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct TraitRef { pub path: Path, pub ref_id: NodeId, @@ -1106,7 +1106,7 @@ impl Visibility { } } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct StructField_ { pub kind: StructFieldKind, pub id: NodeId, @@ -1125,7 +1125,7 @@ impl StructField_ { pub type StructField = Spanned; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum StructFieldKind { NamedField(Ident, Visibility), /// Element of a tuple-like struct @@ -1141,7 +1141,7 @@ impl StructFieldKind { } } -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct StructDef { /// Fields, not including ctor pub fields: Vec, @@ -1158,7 +1158,7 @@ pub struct StructDef { FIXME (#3300): Should allow items to be anonymous. Right now we just use dummy names for anon items. */ -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct Item { pub ident: Ident, pub attrs: Vec, @@ -1168,7 +1168,7 @@ pub struct Item { pub span: Span, } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Item_ { ItemStatic(P, Mutability, Gc), ItemFn(P, FnStyle, Abi, Generics, P), @@ -1191,7 +1191,7 @@ pub enum Item_ { ItemMac(Mac), } -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct ForeignItem { pub ident: Ident, pub attrs: Vec, @@ -1201,7 +1201,7 @@ pub struct ForeignItem { pub vis: Visibility, } -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum ForeignItem_ { ForeignItemFn(P, Generics), ForeignItemStatic(P, /* is_mutbl */ bool), @@ -1210,7 +1210,7 @@ pub enum ForeignItem_ { /// The data we save and restore about an inlined item or method. This is not /// part of the AST that we parse from a file, but it becomes part of the tree /// that we trans. -#[deriving(PartialEq, Eq, Encodable, Decodable, Hash)] +#[deriving(PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum InlinedItem { IIItem(Gc), IIMethod(DefId /* impl id */, bool /* is provided */, Gc), diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 530ea01311238..7eb6709919aaf 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use std::fmt; use std::default::Default; use std::hash; use std::{mem, raw, ptr, slice}; @@ -22,6 +23,17 @@ pub struct OwnedSlice { len: uint, } +impl fmt::Show for OwnedSlice { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + try!("OwnedSlice {{".fmt(fmt)); + for i in self.iter() { + try!(i.fmt(fmt)); + } + try!("}}".fmt(fmt)); + Ok(()) + } +} + #[unsafe_destructor] impl Drop for OwnedSlice { fn drop(&mut self) {