Skip to content

Commit 3ddc270

Browse files
committed
Auto merge of rust-lang#39224 - GuillaumeGomez:os_string_urls, r=frewsxcv
Add missing urls for OsStr and OsString r? @frewsxcv
2 parents 98c3128 + 27123d1 commit 3ddc270

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

src/libstd/ffi/os_str.rs

+28-9
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,20 @@ use sys_common::{AsInner, IntoInner, FromInner};
3131
///
3232
/// * In Rust, strings are always valid UTF-8, but may contain zeros.
3333
///
34-
/// `OsString` and `OsStr` bridge this gap by simultaneously representing Rust
34+
/// `OsString` and [`OsStr`] bridge this gap by simultaneously representing Rust
3535
/// and platform-native string values, and in particular allowing a Rust string
3636
/// to be converted into an "OS" string with no cost.
37+
///
38+
/// [`OsStr`]: struct.OsStr.html
3739
#[derive(Clone)]
3840
#[stable(feature = "rust1", since = "1.0.0")]
3941
pub struct OsString {
4042
inner: Buf
4143
}
4244

43-
/// Slices into OS strings (see `OsString`).
45+
/// Slices into OS strings (see [`OsString`]).
46+
///
47+
/// [`OsString`]: struct.OsString.html
4448
#[stable(feature = "rust1", since = "1.0.0")]
4549
pub struct OsStr {
4650
inner: Slice
@@ -61,7 +65,9 @@ impl OsString {
6165
OsString { inner: Buf::from_string(String::new()) }
6266
}
6367

64-
/// Converts to an `OsStr` slice.
68+
/// Converts to an [`OsStr`] slice.
69+
///
70+
/// [`OsStr`]: struct.OsStr.html
6571
///
6672
/// # Examples
6773
///
@@ -77,10 +83,12 @@ impl OsString {
7783
self
7884
}
7985

80-
/// Converts the `OsString` into a `String` if it contains valid Unicode data.
86+
/// Converts the `OsString` into a [`String`] if it contains valid Unicode data.
8187
///
8288
/// On failure, ownership of the original `OsString` is returned.
8389
///
90+
/// [`String`]: ../../std/string/struct.String.html
91+
///
8492
/// # Examples
8593
///
8694
/// ```
@@ -95,7 +103,9 @@ impl OsString {
95103
self.inner.into_string().map_err(|buf| OsString { inner: buf} )
96104
}
97105

98-
/// Extends the string with the given `&OsStr` slice.
106+
/// Extends the string with the given [`&OsStr`] slice.
107+
///
108+
/// [`&OsStr`]: struct.OsStr.html
99109
///
100110
/// # Examples
101111
///
@@ -329,10 +339,12 @@ impl OsStr {
329339
unsafe { mem::transmute(inner) }
330340
}
331341

332-
/// Yields a `&str` slice if the `OsStr` is valid Unicode.
342+
/// Yields a [`&str`] slice if the `OsStr` is valid Unicode.
333343
///
334344
/// This conversion may entail doing a check for UTF-8 validity.
335345
///
346+
/// [`&str`]: ../../std/primitive.str.html
347+
///
336348
/// # Examples
337349
///
338350
/// ```
@@ -346,10 +358,13 @@ impl OsStr {
346358
self.inner.to_str()
347359
}
348360

349-
/// Converts an `OsStr` to a `Cow<str>`.
361+
/// Converts an `OsStr` to a [`Cow`]`<`[`str`]`>`.
350362
///
351363
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
352364
///
365+
/// [`Cow`]: ../../std/borrow/enum.Cow.html
366+
/// [`str`]: ../../std/primitive.str.html
367+
///
353368
/// # Examples
354369
///
355370
/// Calling `to_string_lossy` on an `OsStr` with valid unicode:
@@ -368,7 +383,9 @@ impl OsStr {
368383
self.inner.to_string_lossy()
369384
}
370385

371-
/// Copies the slice into an owned `OsString`.
386+
/// Copies the slice into an owned [`OsString`].
387+
///
388+
/// [`OsString`]: struct.OsString.html
372389
#[stable(feature = "rust1", since = "1.0.0")]
373390
pub fn to_os_string(&self) -> OsString {
374391
OsString { inner: self.inner.to_owned() }
@@ -397,10 +414,12 @@ impl OsStr {
397414
/// Note that this does **not** return the number of bytes in this string
398415
/// as, for example, OS strings on Windows are encoded as a list of `u16`
399416
/// rather than a list of bytes. This number is simply useful for passing to
400-
/// other methods like `OsString::with_capacity` to avoid reallocations.
417+
/// other methods like [`OsString::with_capacity`] to avoid reallocations.
401418
///
402419
/// See `OsStr` introduction for more information about encoding.
403420
///
421+
/// [`OsString::with_capacity`]: struct.OsString.html#method.with_capacity
422+
///
404423
/// # Examples
405424
///
406425
/// ```

0 commit comments

Comments
 (0)