@@ -468,7 +468,7 @@ wrong, and the situation is more subtle:
468
468
469
469
* Windows, however, works with * arbitrary ` u16 ` sequences* that are roughly
470
470
interpreted at UTF-16, but may not actually be valid UTF-16 -- an "encoding"
471
- often call UCS-2; see http://justsolve.archiveteam.org/wiki/UCS-2 for a bit
471
+ often called UCS-2; see http://justsolve.archiveteam.org/wiki/UCS-2 for a bit
472
472
more detail.
473
473
474
474
What this means is that all of Rust's platforms go beyond Unicode, but they do
@@ -497,13 +497,13 @@ offers the possibility of platform-specific APIs.
497
497
other words, making up some methods:
498
498
499
499
``` rust
500
- my_ut8_data . to_wtf_8 (). to_ucs2 (). as_u16_slice () == my_utf8_data . to_utf16 (). as_16_slice ()
500
+ my_ut8_data . to_wtf8 (). to_ucs2 (). as_u16_slice () == my_utf8_data . to_utf16 (). as_u16_slice ()
501
501
```
502
502
503
503
* Valid UTF-16 data re-encoded as WTF-8 produces the corresponding UTF-8 data:
504
504
505
505
``` rust
506
- my_utf16_data . to_wtf_8 (). as_bytes () == my_utf16_data . to_utf8 (). as_bytes ()
506
+ my_utf16_data . to_wtf8 (). as_bytes () == my_utf16_data . to_utf8 (). as_bytes ()
507
507
```
508
508
509
509
These two properties mean that, when working with Unicode data, the WTF-8
@@ -529,14 +529,14 @@ first proposed in the
529
529
to introduce new string and string slice types that (opaquely) represent
530
530
* platform-sensitive strings* , housed in the ` std::os_str ` module.
531
531
532
- The ` OsStrBuf ` type is analogous to ` String ` , and ` OsStr ` is analogous to ` str ` .
532
+ The ` OsString ` type is analogous to ` String ` , and ` OsStr ` is analogous to ` str ` .
533
533
Their backing implementation is platform-dependent, but they offer a
534
534
cross-platform API:
535
535
536
536
``` rust
537
537
pub mod os_str {
538
538
/// Owned OS strings
539
- struct OsStrBuf {
539
+ struct OsString {
540
540
inner : imp :: Buf
541
541
}
542
542
/// Slices into OS strings
@@ -559,18 +559,18 @@ pub mod os_str {
559
559
...
560
560
}
561
561
562
- impl OsStrBuf {
563
- pub fn from_string (String ) -> OsStrBuf ;
564
- pub fn from_str (& str ) -> OsStrBuf ;
562
+ impl OsString {
563
+ pub fn from_string (String ) -> OsString ;
564
+ pub fn from_str (& str ) -> OsString ;
565
565
pub fn as_slice (& self ) -> & OsStr ;
566
- pub fn into_string (Self ) -> Result <String , OsStrBuf >;
566
+ pub fn into_string (Self ) -> Result <String , OsString >;
567
567
pub fn into_string_lossy (Self ) -> String ;
568
568
569
569
// and ultimately other functionality typically found on vectors,
570
570
// but CRUCIALLY NOT as_bytes
571
571
}
572
572
573
- impl Deref <OsStr > for OsStrBuf { ... }
573
+ impl Deref <OsStr > for OsString { ... }
574
574
575
575
impl OsStr {
576
576
pub fn from_str (value : & str ) -> & OsStr ;
@@ -581,12 +581,12 @@ pub mod os_str {
581
581
// but CRUCIALLY NOT as_bytes
582
582
}
583
583
584
- trait IntoOsStrBuf {
585
- fn into_os_str_buf (self ) -> OsStrBuf ;
584
+ trait IntoOsString {
585
+ fn into_os_str_buf (self ) -> OsString ;
586
586
}
587
587
588
- impl IntoOsStrBuf for OsStrBuf { ... }
589
- impl <'a > IntoOsStrBuf for & 'a OsStr { ... }
588
+ impl IntoOsString for OsString { ... }
589
+ impl <'a > IntoOsString for & 'a OsStr { ... }
590
590
591
591
...
592
592
}
@@ -612,12 +612,12 @@ reveals more about the space of possible values:
612
612
pub mod os {
613
613
#[cfg(unix)]
614
614
pub mod unix {
615
- trait OsStrBufExt {
615
+ trait OsStringExt {
616
616
fn from_vec (Vec <u8 >) -> Self ;
617
617
fn into_vec (Self ) -> Vec <u8 >;
618
618
}
619
619
620
- impl OsStrBufExt for os_str :: OsStrBuf { ... }
620
+ impl OsStringExt for os_str :: OsString { ... }
621
621
622
622
trait OsStrExt {
623
623
fn as_byte_slice (& self ) -> & [u8 ];
@@ -633,11 +633,11 @@ pub mod os {
633
633
pub mod windows {
634
634
// The following extension traits provide a UCS-2 view of OS strings
635
635
636
- trait OsStrBufExt {
636
+ trait OsStringExt {
637
637
fn from_wide_slice (& [u16 ]) -> Self ;
638
638
}
639
639
640
- impl OsStrBufExt for os_str :: OsStrBuf { ... }
640
+ impl OsStringExt for os_str :: OsString { ... }
641
641
642
642
trait OsStrExt {
643
643
fn to_wide_vec (& self ) -> Vec <u16 >;
@@ -773,15 +773,15 @@ principles or visions) are outside the scope of this RFC.
773
773
774
774
(Text from @SimonSapin )
775
775
776
- Rather than WTF-8, ` OsStr ` and ` OsStrBuf ` on Windows could use
776
+ Rather than WTF-8, ` OsStr ` and ` OsString ` on Windows could use
777
777
potentially-ill-formed UTF-16 (a.k.a. "wide" strings), with a
778
778
different cost trade off.
779
779
780
780
Upside:
781
- * No conversion between ` OsStr ` / ` OsStrBuf ` and OS calls.
781
+ * No conversion between ` OsStr ` / ` OsString ` and OS calls.
782
782
783
783
Downsides:
784
- * More expensive conversions between ` OsStr ` / ` OsStrBuf ` and ` str ` / ` String ` .
784
+ * More expensive conversions between ` OsStr ` / ` OsString ` and ` str ` / ` String ` .
785
785
* These conversions have inconsistent performance characteristics between platforms. (Need to allocate on Windows, but not on Unix.)
786
786
* Some of them return ` Cow ` , which has some ergonomic hit.
787
787
@@ -797,14 +797,14 @@ pub mod os_str {
797
797
}
798
798
799
799
impl OsStr {
800
- pub fn from_str (& str ) -> Cow <OsStrBuf , OsStr >;
800
+ pub fn from_str (& str ) -> Cow <OsString , OsStr >;
801
801
pub fn to_string (& self ) -> Option <CowString >;
802
802
pub fn to_string_lossy (& self ) -> CowString ;
803
803
}
804
804
805
805
#[cfg(windows)]
806
806
pub mod windows {
807
- trait OsStrBufExt {
807
+ trait OsStringExt {
808
808
fn from_wide_slice (& [u16 ]) -> Self ;
809
809
fn from_wide_vec (Vec <u16 >) -> Self ;
810
810
fn into_wide_vec (self ) -> Vec <u16 >;
0 commit comments