@@ -31,16 +31,20 @@ use sys_common::{AsInner, IntoInner, FromInner};
31
31
///
32
32
/// * In Rust, strings are always valid UTF-8, but may contain zeros.
33
33
///
34
- /// `OsString` and `OsStr` bridge this gap by simultaneously representing Rust
34
+ /// `OsString` and [ `OsStr`] bridge this gap by simultaneously representing Rust
35
35
/// and platform-native string values, and in particular allowing a Rust string
36
36
/// to be converted into an "OS" string with no cost.
37
+ ///
38
+ /// [`OsStr`]: struct.OsStr.html
37
39
#[ derive( Clone ) ]
38
40
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
39
41
pub struct OsString {
40
42
inner : Buf
41
43
}
42
44
43
- /// Slices into OS strings (see `OsString`).
45
+ /// Slices into OS strings (see [`OsString`]).
46
+ ///
47
+ /// [`OsString`]: struct.OsString.html
44
48
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
45
49
pub struct OsStr {
46
50
inner : Slice
@@ -61,7 +65,9 @@ impl OsString {
61
65
OsString { inner : Buf :: from_string ( String :: new ( ) ) }
62
66
}
63
67
64
- /// Converts to an `OsStr` slice.
68
+ /// Converts to an [`OsStr`] slice.
69
+ ///
70
+ /// [`OsStr`]: struct.OsStr.html
65
71
///
66
72
/// # Examples
67
73
///
@@ -77,10 +83,12 @@ impl OsString {
77
83
self
78
84
}
79
85
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.
81
87
///
82
88
/// On failure, ownership of the original `OsString` is returned.
83
89
///
90
+ /// [`String`]: ../../std/string/struct.String.html
91
+ ///
84
92
/// # Examples
85
93
///
86
94
/// ```
@@ -95,7 +103,9 @@ impl OsString {
95
103
self . inner . into_string ( ) . map_err ( |buf| OsString { inner : buf} )
96
104
}
97
105
98
- /// Extends the string with the given `&OsStr` slice.
106
+ /// Extends the string with the given [`&OsStr`] slice.
107
+ ///
108
+ /// [`&OsStr`]: struct.OsStr.html
99
109
///
100
110
/// # Examples
101
111
///
@@ -329,10 +339,12 @@ impl OsStr {
329
339
unsafe { mem:: transmute ( inner) }
330
340
}
331
341
332
- /// Yields a `&str` slice if the `OsStr` is valid Unicode.
342
+ /// Yields a [ `&str`] slice if the `OsStr` is valid Unicode.
333
343
///
334
344
/// This conversion may entail doing a check for UTF-8 validity.
335
345
///
346
+ /// [`&str`]: ../../std/primitive.str.html
347
+ ///
336
348
/// # Examples
337
349
///
338
350
/// ```
@@ -346,10 +358,13 @@ impl OsStr {
346
358
self . inner . to_str ( )
347
359
}
348
360
349
- /// Converts an `OsStr` to a `Cow< str>`.
361
+ /// Converts an `OsStr` to a [ `Cow`]`<`[` str`]` >`.
350
362
///
351
363
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
352
364
///
365
+ /// [`Cow`]: ../../std/borrow/enum.Cow.html
366
+ /// [`str`]: ../../std/primitive.str.html
367
+ ///
353
368
/// # Examples
354
369
///
355
370
/// Calling `to_string_lossy` on an `OsStr` with valid unicode:
@@ -368,7 +383,9 @@ impl OsStr {
368
383
self . inner . to_string_lossy ( )
369
384
}
370
385
371
- /// Copies the slice into an owned `OsString`.
386
+ /// Copies the slice into an owned [`OsString`].
387
+ ///
388
+ /// [`OsString`]: struct.OsString.html
372
389
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
373
390
pub fn to_os_string ( & self ) -> OsString {
374
391
OsString { inner : self . inner . to_owned ( ) }
@@ -397,10 +414,12 @@ impl OsStr {
397
414
/// Note that this does **not** return the number of bytes in this string
398
415
/// as, for example, OS strings on Windows are encoded as a list of `u16`
399
416
/// 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.
401
418
///
402
419
/// See `OsStr` introduction for more information about encoding.
403
420
///
421
+ /// [`OsString::with_capacity`]: struct.OsString.html#method.with_capacity
422
+ ///
404
423
/// # Examples
405
424
///
406
425
/// ```
0 commit comments