diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:10:50 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:10:50 -0700 |
| commit | 753efb5042563dd34a4a524197fa14a129ddf449 (patch) | |
| tree | c7f2301e6ba8d7e0e6f16674905a36c55b853085 /src/libstd/ffi | |
| parent | 388e5aee1e3df9e25f69815ffebfaa39e2167b5f (diff) | |
| parent | 57cf2decf755c6eea3275e2a87862756eb8c62ca (diff) | |
| download | rust-753efb5042563dd34a4a524197fa14a129ddf449.tar.gz rust-753efb5042563dd34a4a524197fa14a129ddf449.zip | |
rollup merge of #23601: nikomatsakis/by-value-index
This is a [breaking-change]. When indexing a generic map (hashmap, etc) using the `[]` operator, it is now necessary to borrow explicitly, so change `map[key]` to `map[&key]` (consistent with the `get` routine). However, indexing of string-valued maps with constant strings can now be written `map["abc"]`. r? @japaric cc @aturon @Gankro
Diffstat (limited to 'src/libstd/ffi')
| -rw-r--r-- | src/libstd/ffi/os_str.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 4d411046632..5851c6e2998 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -133,6 +133,7 @@ impl<'a> From<&'a OsStr> for OsString { } } +#[cfg(stage0)] #[stable(feature = "rust1", since = "1.0.0")] impl ops::Index<ops::RangeFull> for OsString { type Output = OsStr; @@ -143,6 +144,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; |
