Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Add capacity guarantees notes for OsString #95394

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions library/std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
/// values, encoded in a less-strict variant of UTF-8. This is useful to
/// understand when handling capacity and length values.
///
/// # Capacity of OsString
///
/// Capacity means UTF-8 byte size for OS strings which created from
/// valid unicode, and not otherwise specified for other contents.
///
/// # Creating an `OsString`
///
/// **From a Rust string**: `OsString` implements
Expand Down Expand Up @@ -188,6 +193,11 @@ impl OsString {
///
/// See main `OsString` documentation information about encoding.
///
/// # Notes
///
/// Capacity means UTF-8 byte size for OS strings which created from
/// valid unicode, and not otherwise specified for other contents.
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -231,6 +241,11 @@ impl OsString {
///
/// See `OsString` introduction for information about encoding.
///
/// # Notes
///
/// Capacity means UTF-8 byte size for OS strings which created from
/// valid unicode, and not otherwise specified for other contents.
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -272,6 +287,11 @@ impl OsString {
/// greater than or equal to `self.len() + additional`. Does nothing if
/// capacity is already sufficient.
///
/// # Notes
///
/// Capacity means UTF-8 byte size for OS strings which created from
/// valid unicode, and not otherwise specified for other contents.
///
/// # Errors
///
/// If the capacity overflows, or the allocator reports a failure, then an error
Expand Down Expand Up @@ -313,6 +333,11 @@ impl OsString {
///
/// [`reserve`]: OsString::reserve
///
/// # Notes
///
/// Capacity means UTF-8 byte size for OS strings which created from
/// valid unicode, and not otherwise specified for other contents.
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -340,6 +365,11 @@ impl OsString {
///
/// [`try_reserve`]: OsString::try_reserve
///
/// # Notes
///
/// Capacity means UTF-8 byte size for OS strings which created from
/// valid unicode, and not otherwise specified for other contents.
///
/// # Errors
///
/// If the capacity overflows, or the allocator reports a failure, then an error
Expand Down Expand Up @@ -399,6 +429,11 @@ impl OsString {
///
/// If the current capacity is less than the lower limit, this is a no-op.
///
/// # Notes
///
/// Capacity means UTF-8 byte size for OS strings which created from
/// valid unicode, and not otherwise specified for other contents.
///
/// # Examples
///
/// ```
Expand Down