|
3 | 3 |
|
4 | 4 | usecrate::ffi::{OsStr,OsString}; |
5 | 5 | usecrate::sealed::Sealed; |
| 6 | +usecrate::sys_common::{AsInner,IntoInner}; |
6 | 7 |
|
7 | | -/// Motor OS-specific extensions to [`OsString`]. |
| 8 | +/// Motor OS–specific extensions to [`OsString`]. |
8 | 9 | /// |
9 | 10 | /// This trait is sealed: it cannot be implemented outside the standard library. |
10 | 11 | /// This is so that future additional methods are not breaking changes. |
11 | 12 | pubtraitOsStringExt:Sealed{ |
12 | | -/// Motor OS strings are utf-8, and thus just strings. |
13 | | -fnas_str(&self) -> &str; |
| 13 | +/// Yields the underlying UTF-8 string of this [`OsString`]. |
| 14 | +/// |
| 15 | +/// OS strings on Motor OS are guaranteed to be UTF-8, so are just strings. |
| 16 | +fninto_string(self) -> String; |
14 | 17 | } |
15 | 18 |
|
16 | 19 | implOsStringExtforOsString{ |
17 | 20 | #[inline] |
18 | | -fnas_str(&self) -> &str{ |
19 | | -self.to_str().unwrap() |
| 21 | +fninto_string(self) -> String{ |
| 22 | +self.into_inner().inner |
20 | 23 | } |
21 | 24 | } |
22 | 25 |
|
23 | | -/// Motor OS-specific extensions to [`OsString`]. |
| 26 | +/// Motor OS–specific extensions to [`OsString`]. |
24 | 27 | /// |
25 | 28 | /// This trait is sealed: it cannot be implemented outside the standard library. |
26 | 29 | /// This is so that future additional methods are not breaking changes. |
27 | 30 | pubtraitOsStrExt:Sealed{ |
28 | | -/// Motor OS strings are utf-8, and thus just strings. |
| 31 | +/// Gets the underlying UTF-8 string view of the [`OsStr`] slice. |
| 32 | +/// |
| 33 | +/// OS strings on Motor OS are guaranteed to be UTF-8, so are just strings. |
29 | 34 | fnas_str(&self) -> &str; |
30 | 35 | } |
31 | 36 |
|
32 | 37 | implOsStrExtforOsStr{ |
33 | 38 | #[inline] |
34 | 39 | fnas_str(&self) -> &str{ |
35 | | -self.to_str().unwrap() |
| 40 | +&self.as_inner().inner |
36 | 41 | } |
37 | 42 | } |
0 commit comments