mozilla/rust — pull request #9192 by Kimundi (2013-09-14 15:59:21+00:00)
Title: Add an SendStr type

A SendStr is a string that can hold either a ~str or a &'static str.
This can be useful as an optimization when an allocation is sometimes needed but the common case is statically known.

Possible use cases include Maps with both static and owned keys, or propagating error messages across task boundaries.

SendStr implements most basic traits in a way that hides the fact that it is an enum; in particular things like order and equality are only determined by the content of the wrapped strings.

This basically reimplements #7599 and has a use case for replacing an Either in #9180.

---

Once #9180 lands I'll add an follow up commit that replaces the `SendableString` there with this type.