diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-03-10 23:13:29 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-03-16 21:56:31 -0500 |
| commit | 633c593bc3f9787decfaf943cdc5659f132ade50 (patch) | |
| tree | a2fbb04334457b3f8fdbe47690c40b5e8835529f /src/libstd/sys/common | |
| parent | 5b118f5ecde796ad62fa349a045d7ad8129b711c (diff) | |
| download | rust-633c593bc3f9787decfaf943cdc5659f132ade50.tar.gz rust-633c593bc3f9787decfaf943cdc5659f132ade50.zip | |
impl<T> [T]
Diffstat (limited to 'src/libstd/sys/common')
| -rw-r--r-- | src/libstd/sys/common/wtf8.rs | 12 |
1 files changed, 12 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 |
