diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-01-07 14:58:31 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-01-07 15:24:21 -0800 |
| commit | 9851b4fbbf327bb1baab3182ce92970d4db22c6c (patch) | |
| tree | cc315eacedccbe68cc91a8cbf676271dc614153c /src/liballoc | |
| parent | 9f1ead8fadc56bad30dc74f5cc50d78af4fbc972 (diff) | |
| download | rust-9851b4fbbf327bb1baab3182ce92970d4db22c6c.tar.gz rust-9851b4fbbf327bb1baab3182ce92970d4db22c6c.zip | |
std: Tweak String implementations
This commit performs a pass over the implementations of the new `String` trait
in the formatting module. Some implementations were removed as a conservative
move pending an upcoming convention about `String` implementations, and some
were added in order to retain consistency across the libraries. Specifically:
* All "smart pointers" implement `String` now, adding missing implementations
for `Arc` and `Rc`.
* The `Vec<T>` and `[T]` types no longer implement `String`.
* The `*const T` and `*mut T` type no longer implement `String`.
* The `()` type no longer implements `String`.
* The `Path` type's `Show` implementation does not surround itself with `Path
{}` (a minor tweak).
All implementations of `String` in this PR were also marked `#[stable]` to
indicate that the types will continue to implement the `String` trait regardless
of what it looks like.
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/arc.rs | 7 | ||||
| -rw-r--r-- | src/liballoc/boxed.rs | 1 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 7 |
3 files changed, 15 insertions, 0 deletions
diff --git a/src/liballoc/arc.rs b/src/liballoc/arc.rs index 5d47602b5e1..8a6afd2e264 100644 --- a/src/liballoc/arc.rs +++ b/src/liballoc/arc.rs @@ -586,6 +586,13 @@ impl<T: fmt::Show> fmt::Show for Arc<T> { } #[stable] +impl<T: fmt::String> fmt::String for Arc<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(&**self, f) + } +} + +#[stable] impl<T: Default + Sync + Send> Default for Arc<T> { #[stable] fn default() -> Arc<T> { Arc::new(Default::default()) } diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index d46f18abf97..1943b1bd34b 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -149,6 +149,7 @@ impl<T: ?Sized + fmt::Show> fmt::Show for Box<T> { } } +#[stable] impl<T: ?Sized + fmt::String> fmt::String for Box<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::String::fmt(&**self, f) diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 67b25427710..867f70df774 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -611,6 +611,13 @@ impl<T: fmt::Show> fmt::Show for Rc<T> { } } +#[stable] +impl<T: fmt::String> fmt::String for Rc<T> { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::String::fmt(&**self, f) + } +} + /// A weak version of `Rc<T>`. /// /// Weak references do not count when determining if the inner value should be dropped. |
