Skip to content

Commit 6506df7

Browse files
Xuanwojoshtriplett
authored andcommitted
std: Add capacity guarantees notes for OsString
Signed-off-by: Xuanwo <[email protected]>
1 parent 10d9ecd commit 6506df7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

library/std/src/ffi/os_str.rs

+35
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
4545
/// values, encoded in a less-strict variant of UTF-8. This is useful to
4646
/// understand when handling capacity and length values.
4747
///
48+
/// # Capacity of OsString
49+
///
50+
/// Capacity means UTF-8 byte size for OS strings which created from
51+
/// valid unicode, and not otherwise specified for other contents.
52+
///
4853
/// # Creating an `OsString`
4954
///
5055
/// **From a Rust string**: `OsString` implements
@@ -188,6 +193,11 @@ impl OsString {
188193
///
189194
/// See main `OsString` documentation information about encoding.
190195
///
196+
/// # Notes
197+
///
198+
/// Capacity means UTF-8 byte size for OS strings which created from
199+
/// valid unicode, and not otherwise specified for other contents.
200+
///
191201
/// # Examples
192202
///
193203
/// ```
@@ -231,6 +241,11 @@ impl OsString {
231241
///
232242
/// See `OsString` introduction for information about encoding.
233243
///
244+
/// # Notes
245+
///
246+
/// Capacity means UTF-8 byte size for OS strings which created from
247+
/// valid unicode, and not otherwise specified for other contents.
248+
///
234249
/// # Examples
235250
///
236251
/// ```
@@ -272,6 +287,11 @@ impl OsString {
272287
/// greater than or equal to `self.len() + additional`. Does nothing if
273288
/// capacity is already sufficient.
274289
///
290+
/// # Notes
291+
///
292+
/// Capacity means UTF-8 byte size for OS strings which created from
293+
/// valid unicode, and not otherwise specified for other contents.
294+
///
275295
/// # Errors
276296
///
277297
/// If the capacity overflows, or the allocator reports a failure, then an error
@@ -313,6 +333,11 @@ impl OsString {
313333
///
314334
/// [`reserve`]: OsString::reserve
315335
///
336+
/// # Notes
337+
///
338+
/// Capacity means UTF-8 byte size for OS strings which created from
339+
/// valid unicode, and not otherwise specified for other contents.
340+
///
316341
/// # Examples
317342
///
318343
/// ```
@@ -340,6 +365,11 @@ impl OsString {
340365
///
341366
/// [`try_reserve`]: OsString::try_reserve
342367
///
368+
/// # Notes
369+
///
370+
/// Capacity means UTF-8 byte size for OS strings which created from
371+
/// valid unicode, and not otherwise specified for other contents.
372+
///
343373
/// # Errors
344374
///
345375
/// If the capacity overflows, or the allocator reports a failure, then an error
@@ -399,6 +429,11 @@ impl OsString {
399429
///
400430
/// If the current capacity is less than the lower limit, this is a no-op.
401431
///
432+
/// # Notes
433+
///
434+
/// Capacity means UTF-8 byte size for OS strings which created from
435+
/// valid unicode, and not otherwise specified for other contents.
436+
///
402437
/// # Examples
403438
///
404439
/// ```

0 commit comments

Comments
 (0)