4949//! ```rust
5050//! #![feature(rustc_private)]
5151//!
52- //! use graphviz::IntoCow;
5352//! use std::io::Write;
5453//! use graphviz as dot;
5554//!
8483//! }
8584//! nodes.sort();
8685//! nodes.dedup();
87- //! nodes.into_cow ()
86+ //! nodes.into ()
8887//! }
8988//!
9089//! fn edges(&'a self) -> dot::Edges<'a,Ed> {
9190//! let &Edges(ref edges) = self;
92- //! (&edges[..]).into_cow ()
91+ //! (&edges[..]).into ()
9392//! }
9493//!
9594//! fn source(&self, e: &Ed) -> Nd { let &(s,_) = e; s }
144143//! Since both the set of nodes and the set of edges are always
145144//! constructed from scratch via iterators, we use the `collect()` method
146145//! from the `Iterator` trait to collect the nodes and edges into freshly
147- //! constructed growable `Vec` values (rather use the `into_cow`
148- //! from the `IntoCow` trait as was used in the first example
149- //! above).
146+ //! constructed growable `Vec` values (rather than using `Cow` as in the
147+ //! first example above).
150148//!
151149//! The output from this example renders four nodes that make up the
152150//! Hasse-diagram for the subsets of the set `{x, y}`. Each edge is
293291
294292use self :: LabelText :: * ;
295293
296- use std:: borrow:: { Cow , ToOwned } ;
294+ use std:: borrow:: Cow ;
297295use std:: io:: prelude:: * ;
298296use std:: io;
299297
@@ -411,8 +409,8 @@ impl<'a> Id<'a> {
411409 ///
412410 /// Passing an invalid string (containing spaces, brackets,
413411 /// quotes, ...) will return an empty `Err` value.
414- pub fn new < Name : IntoCow < ' a , str > > ( name : Name ) -> Result < Id < ' a > , ( ) > {
415- let name = name. into_cow ( ) ;
412+ pub fn new < Name : Into < Cow < ' a , str > > > ( name : Name ) -> Result < Id < ' a > , ( ) > {
413+ let name = name. into ( ) ;
416414 match name. chars ( ) . next ( ) {
417415 Some ( c) if c. is_ascii_alphabetic ( ) || c == '_' => { }
418416 _ => return Err ( ( ) ) ,
@@ -473,7 +471,7 @@ pub trait Labeller<'a> {
473471 /// The label need not be unique, and may be the empty string; the
474472 /// default is in fact the empty string.
475473 fn edge_label ( & ' a self , _e : & Self :: Edge ) -> LabelText < ' a > {
476- LabelStr ( "" . into_cow ( ) )
474+ LabelStr ( "" . into ( ) )
477475 }
478476
479477 /// Maps `n` to a style that will be used in the rendered output.
@@ -497,16 +495,16 @@ pub fn escape_html(s: &str) -> String {
497495}
498496
499497impl < ' a > LabelText < ' a > {
500- pub fn label < S : IntoCow < ' a , str > > ( s : S ) -> LabelText < ' a > {
501- LabelStr ( s. into_cow ( ) )
498+ pub fn label < S : Into < Cow < ' a , str > > > ( s : S ) -> LabelText < ' a > {
499+ LabelStr ( s. into ( ) )
502500 }
503501
504- pub fn escaped < S : IntoCow < ' a , str > > ( s : S ) -> LabelText < ' a > {
505- EscStr ( s. into_cow ( ) )
502+ pub fn escaped < S : Into < Cow < ' a , str > > > ( s : S ) -> LabelText < ' a > {
503+ EscStr ( s. into ( ) )
506504 }
507505
508- pub fn html < S : IntoCow < ' a , str > > ( s : S ) -> LabelText < ' a > {
509- HtmlStr ( s. into_cow ( ) )
506+ pub fn html < S : Into < Cow < ' a , str > > > ( s : S ) -> LabelText < ' a > {
507+ HtmlStr ( s. into ( ) )
510508 }
511509
512510 fn escape_char < F > ( c : char , mut f : F )
@@ -550,7 +548,7 @@ impl<'a> LabelText<'a> {
550548 EscStr ( s) => s,
551549 LabelStr ( s) => {
552550 if s. contains ( '\\' ) {
553- ( & * s) . escape_default ( ) . into_cow ( )
551+ ( & * s) . escape_default ( ) . into ( )
554552 } else {
555553 s
556554 }
@@ -570,7 +568,7 @@ impl<'a> LabelText<'a> {
570568 let suffix = suffix. pre_escaped_content ( ) ;
571569 prefix. push_str ( r"\n\n" ) ;
572570 prefix. push_str ( & suffix) ;
573- EscStr ( prefix. into_cow ( ) )
571+ EscStr ( prefix. into ( ) )
574572 }
575573}
576574
@@ -696,48 +694,13 @@ pub fn render_opts<'a, N, E, G, W>(g: &'a G,
696694 writeln ! ( w, "}}" )
697695}
698696
699- pub trait IntoCow < ' a , B : ?Sized > where B : ToOwned {
700- fn into_cow ( self ) -> Cow < ' a , B > ;
701- }
702-
703- impl < ' a > IntoCow < ' a , str > for String {
704- fn into_cow ( self ) -> Cow < ' a , str > {
705- Cow :: Owned ( self )
706- }
707- }
708-
709- impl < ' a > IntoCow < ' a , str > for & ' a str {
710- fn into_cow ( self ) -> Cow < ' a , str > {
711- Cow :: Borrowed ( self )
712- }
713- }
714-
715- impl < ' a > IntoCow < ' a , str > for Cow < ' a , str > {
716- fn into_cow ( self ) -> Cow < ' a , str > {
717- self
718- }
719- }
720-
721- impl < ' a , T : Clone > IntoCow < ' a , [ T ] > for Vec < T > {
722- fn into_cow ( self ) -> Cow < ' a , [ T ] > {
723- Cow :: Owned ( self )
724- }
725- }
726-
727- impl < ' a , T : Clone > IntoCow < ' a , [ T ] > for & ' a [ T ] {
728- fn into_cow ( self ) -> Cow < ' a , [ T ] > {
729- Cow :: Borrowed ( self )
730- }
731- }
732-
733697#[ cfg( test) ]
734698mod tests {
735699 use self :: NodeLabels :: * ;
736700 use super :: { Id , Labeller , Nodes , Edges , GraphWalk , render, Style } ;
737701 use super :: LabelText :: { self , LabelStr , EscStr , HtmlStr } ;
738702 use std:: io;
739703 use std:: io:: prelude:: * ;
740- use IntoCow ;
741704
742705 /// each node is an index in a vector in the graph.
743706 type Node = usize ;
@@ -852,12 +815,12 @@ mod tests {
852815 }
853816 fn node_label ( & ' a self , n : & Node ) -> LabelText < ' a > {
854817 match self . node_labels [ * n] {
855- Some ( ref l) => LabelStr ( l. into_cow ( ) ) ,
818+ Some ( l) => LabelStr ( l. into ( ) ) ,
856819 None => LabelStr ( id_name ( n) . name ( ) ) ,
857820 }
858821 }
859822 fn edge_label ( & ' a self , e : & & ' a Edge ) -> LabelText < ' a > {
860- LabelStr ( e. label . into_cow ( ) )
823+ LabelStr ( e. label . into ( ) )
861824 }
862825 fn node_style ( & ' a self , n : & Node ) -> Style {
863826 self . node_styles [ * n]
0 commit comments