about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-12-12 13:23:21 +1300
committerNick Cameron <ncameron@mozilla.com>2014-12-16 17:05:33 +1300
commit769aa0a7b378a7b71f5bcbec3485fe171ff4f3b9 (patch)
tree6c0039840b240cb1f9386ef687b9a63c6926d404 /src/libstd
parent0669a432a2e09ad08886cb2138dbe9f5d681fb7f (diff)
downloadrust-769aa0a7b378a7b71f5bcbec3485fe171ff4f3b9.tar.gz
rust-769aa0a7b378a7b71f5bcbec3485fe171ff4f3b9.zip
Remove the double auto-ref on arrays/strings as receivers
Part of #18469

[breaking-change]

A receiver will only ever get a single auto-reference. Previously arrays and strings would get two, e.g., [T] would be auto-ref'ed to &&[T]. This is usually apparent when a trait is implemented for `&[T]` and has a method takes self by reference. The usual solution is to implement the trait for `[T]` (the DST form).
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ascii.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs
index ad2167214a7..81e8e4e4d7c 100644
--- a/src/libstd/ascii.rs
+++ b/src/libstd/ascii.rs
@@ -170,7 +170,7 @@ impl<'a> fmt::Show for Ascii {
 
 /// Trait for converting into an ascii type.
 #[experimental = "may be replaced by generic conversion traits"]
-pub trait AsciiCast<T> {
+pub trait AsciiCast<T> for Sized? {
     /// Convert to an ascii type, panic on non-ASCII input.
     #[inline]
     fn to_ascii(&self) -> T {
@@ -196,10 +196,10 @@ pub trait AsciiCast<T> {
 }
 
 #[experimental = "may be replaced by generic conversion traits"]
-impl<'a> AsciiCast<&'a[Ascii]> for &'a [u8] {
+impl<'a> AsciiCast<&'a[Ascii]> for [u8] {
     #[inline]
     unsafe fn to_ascii_nocheck(&self) -> &'a[Ascii] {
-        mem::transmute(*self)
+        mem::transmute(self)
     }
 
     #[inline]
@@ -212,10 +212,10 @@ impl<'a> AsciiCast<&'a[Ascii]> for &'a [u8] {
 }
 
 #[experimental = "may be replaced by generic conversion traits"]
-impl<'a> AsciiCast<&'a [Ascii]> for &'a str {
+impl<'a> AsciiCast<&'a [Ascii]> for str {
     #[inline]
     unsafe fn to_ascii_nocheck(&self) -> &'a [Ascii] {
-        mem::transmute(*self)
+        mem::transmute(self)
     }
 
     #[inline]