rust-lang/rust — pull request #19252 by japaric (2014-11-23 21:15:55+00:00)
Title: [WIP] Deprecate MaybeOwned[Vector] in favor of Cow

- Add `IntoCow` trait
- Add `CowString`/`CowVec` type aliases (to `Cow<'_, String, str>`/`Cow<'_, Vec, [T]>` respectively)
- `Cow` implements: `Show`, `Hash`, `[Partial]{Eq,Ord}`

[breaking-change]s:

- libcollections: `SendStr` is now an alias to `CowString<'static>` (it was aliased to `MaybeOwned<'static>`)
- libgraphviz:
- `LabelText` variants wrap `CowString` instead of `MaybeOwned`
- `Nodes` and `Edges` are now type aliases to `CowVec` (they were aliased to `MaybeOwnedVec`)
- These functions now accept/return `Cow` instead of `MaybeOwned[Vector]`:
- libregex: `Replacer::reg_replace`
- libcollections: `str::from_utf8_lossy`
- libgraphviz: `Id::new`, `Id::name`, `LabelText::pre_escaped_content`
- libstd: `TaskBuilder::named`

---

Left to do:
- Mark `MaybeOwned[Vector]` as deprecated
- Fix the docs where it may have gone wrong

Other things that we may want to do:
- Add `IntoCow` to the prelude (since `IntoMaybeOwned` is in the prelude)
- Add `is_owned`/`is_borrowed` inherent methods to `Cow` (`MaybeOwned` has these methods)

cc @aturon