|
92 | 92 | //! your code can detect errors in case the environment variable did
|
93 | 93 | //! not in fact contain valid Unicode data.
|
94 | 94 | //!
|
95 |
| -//! * [`OsStr`] represents a borrowed string slice in a format that |
96 |
| -//! can be passed to the operating system. It can be converted into |
97 |
| -//! an UTF-8 Rust string slice in a similar way to `OsString`. |
| 95 | +//! * [`OsStr`] represents a borrowed reference to a string in a |
| 96 | +//! format that can be passed to the operating system. It can be |
| 97 | +//! converted into an UTF-8 Rust string slice in a similar way to |
| 98 | +//! `OsString`. |
| 99 | +//! |
| 100 | +//! # Conversions |
| 101 | +//! |
| 102 | +//! ## On Unix |
| 103 | +//! |
| 104 | +//! On Unix, [`OsStr`] implements the `std::os::unix:ffi::`[`OsStrExt`][unix.OsStrExt] trait, which |
| 105 | +//! augments it with two methods, [`from_bytes`] and [`as_bytes`]. These do inexpensive conversions |
| 106 | +//! from and to UTF-8 byte slices. |
| 107 | +//! |
| 108 | +//! Additionally, on Unix [`OsString`] implements the |
| 109 | +//! `std::os::unix:ffi::`[`OsStringExt`][unix.OsStringExt] trait, |
| 110 | +//! which provides [`from_vec`] and [`into_vec`] methods that consume |
| 111 | +//! their arguments, and take or produce vectors of [`u8`]. |
| 112 | +//! |
| 113 | +//! ## On Windows |
| 114 | +//! |
| 115 | +//! On Windows, [`OsStr`] implements the `std::os::windows::ffi::`[`OsStrExt`][windows.OsStrExt] |
| 116 | +//! trait, which provides an [`encode_wide`] method. This provides an iterator that can be |
| 117 | +//! [`collect`]ed into a vector of [`u16`]. |
| 118 | +//! |
| 119 | +//! Additionally, on Windows [`OsString`] implements the |
| 120 | +//! `std::os::windows:ffi::`[`OsStringExt`][windows.OsStringExt] trait, which provides a |
| 121 | +//! [`from_wide`] method. The result of this method is an `OsString` which can be round-tripped to |
| 122 | +//! a Windows string losslessly. |
98 | 123 | //!
|
99 | 124 | //! [`String`]: ../string/struct.String.html
|
100 | 125 | //! [`str`]: ../primitive.str.html
|
101 | 126 | //! [`char`]: ../primitive.char.html
|
| 127 | +//! [`u8`]: ../primitive.u8.html |
| 128 | +//! [`u16`]: ../primitive.u16.html |
102 | 129 | //! [Unicode scalar value]: http://www.unicode.org/glossary/#unicode_scalar_value
|
103 | 130 | //! [Unicode code point]: http://www.unicode.org/glossary/#code_point
|
104 | 131 | //! [`CString`]: struct.CString.html
|
|
108 | 135 | //! [`env::set_var()`]: ../env/fn.set_var.html
|
109 | 136 | //! [`env::var_os()`]: ../env/fn.var_os.html
|
110 | 137 | //! [`Result<>`]: ../result/enum.Result.html
|
| 138 | +//! [unix.OsStringExt]: ../os/unix/ffi/trait.OsStringExt.html |
| 139 | +//! [`from_vec`]: ../os/unix/ffi/trait.OsStringExt.html#tymethod.from_vec |
| 140 | +//! [`into_vec`]: ../os/unix/ffi/trait.OsStringExt.html#tymethod.into_vec |
| 141 | +//! [unix.OsStrExt]: ../os/unix/ffi/trait.OsStrExt.html |
| 142 | +//! [`from_bytes`]: ../os/unix/ffi/trait.OsStrExt.html#tymethod.from_bytes |
| 143 | +//! [`as_bytes`]: ../os/unix/ffi/trait.OsStrExt.html#tymethod.as_bytes |
| 144 | +//! [`OsStrExt`]: ../os/unix/ffi/trait.OsStrExt.html |
| 145 | +//! [windows.OsStrExt]: ../os/windows/ffi/trait.OsStrExt.html |
| 146 | +//! [`encode_wide`]: ../os/windows/ffi/trait.OsStrExt.html#tymethod.encode_wide |
| 147 | +//! [`collect`]: ../iter/trait.Iterator.html#method.collect |
| 148 | +//! [windows.OsStringExt]: ../os/windows/ffi/trait.OsStringExt.html |
| 149 | +//! [`from_wide`]: ../os/windows/ffi/trait.OsStringExt.html#tymethod.from_wide |
111 | 150 |
|
112 | 151 | #![stable(feature = "rust1", since = "1.0.0")]
|
113 | 152 |
|
|
0 commit comments