diff options
| author | bors <bors@rust-lang.org> | 2015-03-17 03:23:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-17 03:23:50 +0000 |
| commit | e46610966f798a083350724461648c6ffdd151f4 (patch) | |
| tree | 70e3113881f1bc7ed6217639e2a67fef9712e4ed /src/libstd/sys | |
| parent | a2572885ab62512a2508868a27c22d615382174a (diff) | |
| parent | b65ebc4094589a65f76a49a790321f1417c67267 (diff) | |
| download | rust-e46610966f798a083350724461648c6ffdd151f4.tar.gz rust-e46610966f798a083350724461648c6ffdd151f4.zip | |
Auto merge of #23104 - japaric:inherent, r=nikomatsakis
- Allow inherent implementations on `char`, `str`, `[T]`, `*const T`, `*mut T` and all the numeric primitives.
- copy `unicode::char::CharExt` methods into `impl char`
- remove `unicode::char::CharExt`, its re-export `std::char::CharExt` and `CharExt` from the prelude
- copy `collections::str::StrExt` methods into `impl str`
- remove `collections::str::StrExt` its re-export `std::str::StrExt`, and `StrExt` from the prelude
- copy `collections::slice::SliceExt` methods into `impl<T> [T]`
- remove `collections::slice::SliceExt` its re-export `std::slice::SliceExt`, and `SliceExt` from the prelude
- copy `core::ptr::PtrExt` methods into `impl<T> *const T`
- remove `core::ptr::PtrExt` its re-export `std::ptr::PtrExt`, and `PtrExt` from the prelude
- copy `core::ptr::PtrExt` and `core::ptr::MutPtrExt` methods into `impl<T> *mut T`
- remove `core::ptr::MutPtrExt` its re-export `std::ptr::MutPtrExt`, and `MutPtrExt` from the prelude
- copy `core::num::Int` and `core::num::SignedInt` methods into `impl i{8,16,32,64,size}`
- copy `core::num::Int` and `core::num::UnsignedInt` methods into `impl u{8,16,32,64,size}`
- remove `core::num::UnsignedInt` and its re-export `std::num::UnsignedInt`
- move `collections` tests into its own crate: `collectionstest`
- copy `core::num::Float` methods into `impl f{32,64}`
Because this PR removes several traits, this is a [breaking-change], however functionality remains unchanged and breakage due to unresolved imports should be minimal. If you encounter an error due to an unresolved import, simply remove the import:
``` diff
fn main() {
- use std::num::UnsignedInt; //~ error: unresolved import `std::num::UnsignedInt`.
-
println!("{}", 8_usize.is_power_of_two());
}
```
---
cc #16862
[preview docs](http://japaric.github.io/inherent/std/index.html)
[unicode::char](http://japaric.github.io/inherent/unicode/primitive.char.html)
[collections::str](http://japaric.github.io/inherent/collections/primitive.str.html)
[std::f32](http://japaric.github.io/inherent/std/primitive.f32.html)
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/common/wtf8.rs | 12 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os_str.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/windows/process2.rs | 1 |
3 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/sys/common/wtf8.rs b/src/libstd/sys/common/wtf8.rs index 4c0b26f8649..dfc88571a82 100644 --- a/src/libstd/sys/common/wtf8.rs +++ b/src/libstd/sys/common/wtf8.rs @@ -172,6 +172,7 @@ impl Wtf8Buf { Wtf8Buf { bytes: string.into_bytes() } } + #[cfg(stage0)] /// Create a WTF-8 string from an UTF-8 `&str` slice. /// /// This copies the content of the slice. @@ -182,6 +183,17 @@ impl Wtf8Buf { Wtf8Buf { bytes: slice::SliceExt::to_vec(str.as_bytes()) } } + #[cfg(not(stage0))] + /// Create a WTF-8 string from an UTF-8 `&str` slice. + /// + /// This copies the content of the slice. + /// + /// Since WTF-8 is a superset of UTF-8, this always succeeds. + #[inline] + pub fn from_str(str: &str) -> Wtf8Buf { + Wtf8Buf { bytes: <[_]>::to_vec(str.as_bytes()) } + } + /// Create a WTF-8 string from a potentially ill-formed UTF-16 slice of 16-bit code units. /// /// This is lossless: calling `.encode_wide()` on the resulting string diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs index 89ab3e1981b..99591480752 100644 --- a/src/libstd/sys/unix/os_str.rs +++ b/src/libstd/sys/unix/os_str.rs @@ -16,6 +16,7 @@ use core::prelude::*; use borrow::Cow; use fmt::{self, Debug}; use vec::Vec; +#[cfg(stage0)] use slice::SliceExt as StdSliceExt; use str; use string::String; diff --git a/src/libstd/sys/windows/process2.rs b/src/libstd/sys/windows/process2.rs index 4fbaabc9ecc..e3cf5da59f0 100644 --- a/src/libstd/sys/windows/process2.rs +++ b/src/libstd/sys/windows/process2.rs @@ -128,6 +128,7 @@ impl Process { use env::split_paths; use mem; use iter::IteratorExt; + #[cfg(stage0)] use str::StrExt; // To have the spawning semantics of unix/windows stay the same, we need to |
