@@ -670,18 +670,22 @@ impl OsStr {
670670 /// Converts a slice of bytes to an OS string slice without checking that the string contains
671671 /// valid `OsStr`-encoded data.
672672 ///
673+ /// The byte encoding is an unspecified, platform-specific, self-synchronizing superset of UTF-8.
674+ /// By being a self-synchronizing superset of UTF-8, this encoding is also a superset of 7-bit
675+ /// ASCII.
676+ ///
673677 /// See the [module's toplevel documentation about conversions][conversions] for safe,
674678 /// cross-platform [conversions] from/to native representations.
675679 ///
676680 /// # Safety
677681 ///
678- /// `OsStr`'s encoding is an unspecified superset of UTF-8 and callers must
679- /// pass in bytes that originated as a mixture of validated UTF-8 and bytes from
680- /// [`OsStr::as_os_str_bytes`] from within the same rust version built for the same target
681- /// platform. For example, reconstructing an `OsStr` from bytes sent over the network or stored
682- /// in a file will likely violate these safety rules. The bytes from `OsStr::as_os_str_bytes`
683- /// may be split either immediately before or immediately after some valid non-empty UTF-8
684- /// substring
682+ /// As the encoding is unspecified, callers must pass in bytes that originated as a mixture of
683+ /// validated UTF-8 and bytes from [`OsStr::as_os_str_bytes`] from within the same rust version
684+ /// built for the same target platform. For example, reconstructing an `OsStr` from bytes sent
685+ /// over the network or stored in a file will likely violate these safety rules.
686+ ///
687+ /// Due to the encoding being self-synchronizing, the bytes from [`OsStr::as_os_str_bytes`] can be
688+ /// split either immediately before or immediately after any valid non-empty UTF-8 substring.
685689 ///
686690 /// # Example
687691 ///
@@ -881,6 +885,10 @@ impl OsStr {
881885 /// Converts an OS string slice to a byte slice. To convert the byte slice back into an OS
882886 /// string slice, use the [`OsStr::from_os_str_bytes_unchecked`] function.
883887 ///
888+ /// The byte encoding is an unspecified, platform-specific, self-synchronizing superset of UTF-8.
889+ /// By being a self-synchronizing superset of UTF-8, this encoding is also a superset of 7-bit
890+ /// ASCII.
891+ ///
884892 /// Note: As the encoding is unspecified, any sub-slice of bytes that is not valid UTF-8 should
885893 /// be treated as opaque and only comparable within the same rust version built for the same
886894 /// target platform. For example, sending the slice over the network or storing it in a file
0 commit comments