about summary refs log tree commit diff
path: root/src/libstd/ffi/os_str.rs
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2015-03-21 19:33:27 -0400
committerNiko Matsakis <niko@alum.mit.edu>2015-03-23 16:55:43 -0400
commitb4d4daf007753dfb04d87b1ffe1c2ad2d8811d5a (patch)
treec35d3d74c271c4ec72678d9d866bcad331a9e706 /src/libstd/ffi/os_str.rs
parentbc1dde468c1613743c919cb9f33923cc9916c5b4 (diff)
downloadrust-b4d4daf007753dfb04d87b1ffe1c2ad2d8811d5a.tar.gz
rust-b4d4daf007753dfb04d87b1ffe1c2ad2d8811d5a.zip
Adjust Index/IndexMut impls. For generic collections, we take
references. For collections whose keys are integers, we take both
references and by-value.
Diffstat (limited to 'src/libstd/ffi/os_str.rs')
-rw-r--r--src/libstd/ffi/os_str.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index feacbf1e98b..290c48b1310 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -103,6 +103,7 @@ impl OsString {
     }
 }
 
+#[cfg(stage0)]
 #[stable(feature = "rust1", since = "1.0.0")]
 impl ops::Index<ops::RangeFull> for OsString {
     type Output = OsStr;
@@ -113,6 +114,17 @@ impl ops::Index<ops::RangeFull> for OsString {
     }
 }
 
+#[cfg(not(stage0))]
+#[stable(feature = "rust1", since = "1.0.0")]
+impl ops::Index<ops::RangeFull> for OsString {
+    type Output = OsStr;
+
+    #[inline]
+    fn index(&self, _index: ops::RangeFull) -> &OsStr {
+        unsafe { mem::transmute(self.inner.as_slice()) }
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl ops::Deref for OsString {
     type Target = OsStr;