Skip to content

Commit 27bd6ad

Browse files
committed
Update OsStrBuf to OsString, fix typos
1 parent 9d80646 commit 27bd6ad

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

text/0517-io-os-reform.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ wrong, and the situation is more subtle:
468468

469469
* Windows, however, works with *arbitrary `u16` sequences* that are roughly
470470
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
472472
more detail.
473473

474474
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.
497497
other words, making up some methods:
498498

499499
```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()
501501
```
502502

503503
* Valid UTF-16 data re-encoded as WTF-8 produces the corresponding UTF-8 data:
504504

505505
```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()
507507
```
508508

509509
These two properties mean that, when working with Unicode data, the WTF-8
@@ -529,14 +529,14 @@ first proposed in the
529529
to introduce new string and string slice types that (opaquely) represent
530530
*platform-sensitive strings*, housed in the `std::os_str` module.
531531

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`.
533533
Their backing implementation is platform-dependent, but they offer a
534534
cross-platform API:
535535

536536
```rust
537537
pub mod os_str {
538538
/// Owned OS strings
539-
struct OsStrBuf {
539+
struct OsString {
540540
inner: imp::Buf
541541
}
542542
/// Slices into OS strings
@@ -559,18 +559,18 @@ pub mod os_str {
559559
...
560560
}
561561

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;
565565
pub fn as_slice(&self) -> &OsStr;
566-
pub fn into_string(Self) -> Result<String, OsStrBuf>;
566+
pub fn into_string(Self) -> Result<String, OsString>;
567567
pub fn into_string_lossy(Self) -> String;
568568

569569
// and ultimately other functionality typically found on vectors,
570570
// but CRUCIALLY NOT as_bytes
571571
}
572572

573-
impl Deref<OsStr> for OsStrBuf { ... }
573+
impl Deref<OsStr> for OsString { ... }
574574

575575
impl OsStr {
576576
pub fn from_str(value: &str) -> &OsStr;
@@ -581,12 +581,12 @@ pub mod os_str {
581581
// but CRUCIALLY NOT as_bytes
582582
}
583583

584-
trait IntoOsStrBuf {
585-
fn into_os_str_buf(self) -> OsStrBuf;
584+
trait IntoOsString {
585+
fn into_os_str_buf(self) -> OsString;
586586
}
587587

588-
impl IntoOsStrBuf for OsStrBuf { ... }
589-
impl<'a> IntoOsStrBuf for &'a OsStr { ... }
588+
impl IntoOsString for OsString { ... }
589+
impl<'a> IntoOsString for &'a OsStr { ... }
590590

591591
...
592592
}
@@ -612,12 +612,12 @@ reveals more about the space of possible values:
612612
pub mod os {
613613
#[cfg(unix)]
614614
pub mod unix {
615-
trait OsStrBufExt {
615+
trait OsStringExt {
616616
fn from_vec(Vec<u8>) -> Self;
617617
fn into_vec(Self) -> Vec<u8>;
618618
}
619619

620-
impl OsStrBufExt for os_str::OsStrBuf { ... }
620+
impl OsStringExt for os_str::OsString { ... }
621621

622622
trait OsStrExt {
623623
fn as_byte_slice(&self) -> &[u8];
@@ -633,11 +633,11 @@ pub mod os {
633633
pub mod windows{
634634
// The following extension traits provide a UCS-2 view of OS strings
635635

636-
trait OsStrBufExt {
636+
trait OsStringExt {
637637
fn from_wide_slice(&[u16]) -> Self;
638638
}
639639

640-
impl OsStrBufExt for os_str::OsStrBuf { ... }
640+
impl OsStringExt for os_str::OsString { ... }
641641

642642
trait OsStrExt {
643643
fn to_wide_vec(&self) -> Vec<u16>;
@@ -773,15 +773,15 @@ principles or visions) are outside the scope of this RFC.
773773

774774
(Text from @SimonSapin)
775775

776-
Rather than WTF-8, `OsStr` and `OsStrBuf` on Windows could use
776+
Rather than WTF-8, `OsStr` and `OsString` on Windows could use
777777
potentially-ill-formed UTF-16 (a.k.a. "wide" strings), with a
778778
different cost trade off.
779779

780780
Upside:
781-
* No conversion between `OsStr` / `OsStrBuf` and OS calls.
781+
* No conversion between `OsStr` / `OsString` and OS calls.
782782

783783
Downsides:
784-
* More expensive conversions between `OsStr` / `OsStrBuf` and `str` / `String`.
784+
* More expensive conversions between `OsStr` / `OsString` and `str` / `String`.
785785
* These conversions have inconsistent performance characteristics between platforms. (Need to allocate on Windows, but not on Unix.)
786786
* Some of them return `Cow`, which has some ergonomic hit.
787787

@@ -797,14 +797,14 @@ pub mod os_str {
797797
}
798798

799799
impl OsStr {
800-
pub fn from_str(&str) -> Cow<OsStrBuf, OsStr>;
800+
pub fn from_str(&str) -> Cow<OsString, OsStr>;
801801
pub fn to_string(&self) -> Option<CowString>;
802802
pub fn to_string_lossy(&self) -> CowString;
803803
}
804804

805805
#[cfg(windows)]
806806
pub mod windows{
807-
trait OsStrBufExt {
807+
trait OsStringExt {
808808
fn from_wide_slice(&[u16]) -> Self;
809809
fn from_wide_vec(Vec<u16>) -> Self;
810810
fn into_wide_vec(self) -> Vec<u16>;

0 commit comments

Comments
 (0)