Skip to content

Commit e85baac

Browse files
committed
Seal OsStr[ing] extension traits.
1 parent df349a9 commit e85baac

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

library/std/src/ffi/os_str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ pub struct OsString {
7676
inner: Buf,
7777
}
7878

79+
/// Allows extension traits within `std`.
80+
#[unstable(feature = "sealed", issue = "none")]
81+
impl crate::sealed::Sealed for OsString {}
82+
7983
/// Borrowed reference to an OS string (see [`OsString`]).
8084
///
8185
/// This type represents a borrowed reference to a string in the operating system's preferred
@@ -100,6 +104,10 @@ pub struct OsStr {
100104
inner: Slice,
101105
}
102106

107+
/// Allows extension traits within `std`.
108+
#[unstable(feature = "sealed", issue = "none")]
109+
impl crate::sealed::Sealed for OsStr {}
110+
103111
impl OsString {
104112
/// Constructs a new empty `OsString`.
105113
///

library/std/src/sys/windows/ext/ffi.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#![stable(feature = "rust1", since = "1.0.0")]
5454

5555
use crate::ffi::{OsStr, OsString};
56+
use crate::sealed::Sealed;
5657
use crate::sys::os_str::Buf;
5758
use crate::sys_common::wtf8::Wtf8Buf;
5859
use crate::sys_common::{AsInner, FromInner};
@@ -62,7 +63,7 @@ pub use crate::sys_common::wtf8::EncodeWide;
6263

6364
/// Windows-specific extensions to [`OsString`].
6465
#[stable(feature = "rust1", since = "1.0.0")]
65-
pub trait OsStringExt {
66+
pub trait OsStringExt: Sealed {
6667
/// Creates an `OsString` from a potentially ill-formed UTF-16 slice of
6768
/// 16-bit code units.
6869
///
@@ -93,7 +94,7 @@ impl OsStringExt for OsString {
9394

9495
/// Windows-specific extensions to [`OsStr`].
9596
#[stable(feature = "rust1", since = "1.0.0")]
96-
pub trait OsStrExt {
97+
pub trait OsStrExt: Sealed {
9798
/// Re-encodes an `OsStr` as a wide character sequence, i.e., potentially
9899
/// ill-formed UTF-16.
99100
///

library/std/src/sys_common/os_str_bytes.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::ffi::{OsStr, OsString};
66
use crate::fmt;
77
use crate::mem;
88
use crate::rc::Rc;
9+
use crate::sealed::Sealed;
910
use crate::str;
1011
use crate::sync::Arc;
1112
use crate::sys_common::bytestring::debug_fmt_bytestring;
@@ -233,7 +234,7 @@ impl Slice {
233234

234235
/// Platform-specific extensions to [`OsString`].
235236
#[stable(feature = "rust1", since = "1.0.0")]
236-
pub trait OsStringExt {
237+
pub trait OsStringExt: Sealed {
237238
/// Creates an [`OsString`] from a byte vector.
238239
///
239240
/// See the module documentation for an example.
@@ -259,7 +260,7 @@ impl OsStringExt for OsString {
259260

260261
/// Platform-specific extensions to [`OsStr`].
261262
#[stable(feature = "rust1", since = "1.0.0")]
262-
pub trait OsStrExt {
263+
pub trait OsStrExt: Sealed {
263264
#[stable(feature = "rust1", since = "1.0.0")]
264265
/// Creates an [`OsStr`] from a byte slice.
265266
///

0 commit comments

Comments
 (0)